Ask Your Question

ros::package::getPath throws bad_alloc

asked 2021-12-30 11:34:14 -0500

JuliusS gravatar image

updated 2021-12-30 11:59:57 -0500

I have quite a large ros repo and everything was working fine for a very long time. For some reason running it after Christmas I started seeing the following:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc [kinematic_simulation-5] process has died [pid 42457, exit code -6, cmd /home/jj/ws/phd_ws/ws/devel/lib/perceptive_mpc/as_mpc_simulation_node /joint_states:=/as_control/joint_states __name:=kinematic_simulation __log:=/home/jj/.ros/log/59272bc6-6995-11ec-9acb-dc8b2894491d/kinematic_simulation-5.log]. log file: /home/jj/.ros/log/59272bc6-6995-11ec-9acb-dc8b2894491d/kinematic_simulation-5*.log

I have isolated the error to the following line:

std::string packagePath = ros::package::getPath("perceptive_mpc");

I'm using melodic, docker. the perceptive_mpc package is built and sourced. The line itself is inside the package so its definitely seen. roslib is inside dependencies. I just have no clue at all. Only seen one issue similar online :

Oh and most interesting of all: if I put an absolute path myself instead of using ros:package:getPath -> everything runs fine.

Absolutely any help or advice appreciated!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-01-02 10:38:59 -0500

JuliusS gravatar image

If anyone encounters this -> Its likely todo with docker setup. In my case it was related to mounting /usr/share. Once I stopped mounting this issue is resolved.

edit flag offensive delete link more


Thank you for sharing the answer

osilva gravatar image osilva  ( 2022-01-03 11:28:09 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-12-30 11:34:14 -0500

Seen: 62 times

Last updated: Jan 02