ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question


asked 2012-05-18 06:13:30 -0600

ads gravatar image

updated 2012-05-18 07:43:26 -0600


I have been trying to add MySQL to my ROS-project and I can compile, link and execute each succesfully separately, but when I combine ROS and calls to MySQL they will still compile and link, but when I run the executable the program gives the following error:

*** glibc detected *** ./DatabaseConnection: free(): invalid pointer: 0x088cf1e8 ***

When I insert the ros::init call in the following code, the invalid pointer problem happens. The problem i basically when I call mysql_init() in DatabaseConnection.

int main(int argc, char **argv)
    ros::init(argc, argv, "Database");

    DatabaseConnection *databaseConnection = new DatabaseConnection();

    return 0;

I have followed the steps described">here with no luck.

I have added the following to my manifest.xml but I'm not sure if I need to add additional linker flags or what the problem is:

  <rosdep name="libmysqlclient-dev"/>
    <cpp lflags="-lmysqlclient"/>

This is the relevant part of my CMakeLists.txt:

rosbuild_add_executable(DatabaseConnection src/DatabaseConnection.cpp)

What am I missing? Any help is much appreciated. Thanks.

EDIT: Included stack from GDB and a backtrace. It seems that it simply dies immediately. I can't really step through the program.


DatabaseConnection [C/C++ Application]  
    /home/adz/ros_workspace/HRIManager/bin/DatabaseConnection [2548] [cores: 0] 
        Thread [1] 2548 [core: 0] (Suspended : Signal : SIGABRT:Aborted)    
            __kernel_vsyscall() at 0xb7fdf424   
            raise() at 0xb7983c8f   
            abort() at 0xb79872b5   
            free() at 0xb79c894d    
            operator delete() at 0xb7b9d80f 
            std::string::_Rep::_M_destroy() at 0xb7b84c4b   
            log4cxx::helpers::Class::registerClass() at 0xb77b1303  
            log4cxx::helpers::ClassRegistration::ClassRegistration() at 0xb77b376b  
            log4cxx::helpers::AppenderAttachableImpl::registerClass() at 0xb77a2b04 


*** glibc detected *** /home/adz/ros_workspace/HRIManager/bin/DatabaseConnection: free(): invalid pointer: 0x0804c1e8 ***
======= Backtrace: =========
======= Memory map: ========
08048000-0804a000 r-xp 00000000 08:06 665000     /home/adz/ros_workspace/HRIManager/bin/DatabaseConnection
0804a000-0804b000 r--p 00001000 08:06 665000     /home/adz/ros_workspace/HRIManager/bin/DatabaseConnection
0804b000-0804c000 rw-p 00002000 08:06 665000     /home/adz/ros_workspace/HRIManager/bin/DatabaseConnection
0804c000-0806d000 rw-p 00000000 00:00 0          [heap]
b6100000-b6121000 rw-p 00000000 00:00 0 
b6121000-b6200000 ---p 00000000 00:00 0 
b62d0000-b62d7000 rw-p 00000000 00:00 0 
b62d7000-b7117000 r--p 00000000 08:06 821143     /usr/lib/
b7117000-b7118000 rw-p 00e3f000 08:06 821143     /usr/lib/
b7118000-b711b000 r-xp 00000000 08:06 655026     /lib/i386-linux-gnu/
b711b000-b711c000 r--p 00002000 08:06 655026     /lib/i386-linux-gnu/
b711c000-b711d000 rw-p 00003000 08:06 655026     /lib/i386-linux-gnu/
b711d000-b711e000 rw-p 00000000 ...
edit retag flag offensive close merge delete


The export tags are not needed. They are only if someone else uses a library that your package exposes.

dornhege gravatar image dornhege  ( 2012-05-18 06:18:22 -0600 )edit

Thanks for your input dornhege. I removed the export flags, however the problem still remains :(

ads gravatar image ads  ( 2012-05-18 06:45:39 -0600 )edit

Try running in gdb to find out which call exactly causes the error. It might be interesting to see a backtrace.

Lorenz gravatar image Lorenz  ( 2012-05-18 06:56:53 -0600 )edit

Lorenz, I added the stack from gdb and a backtrace. It seems that the program dies immediately and I am not able to step through it.

ads gravatar image ads  ( 2012-05-18 07:44:34 -0600 )edit

I just noticed that /usr/lib/i386-linux-gnu/ is in the backtrace. I am running and I remember the linker warning me: /usr/bin/ld: warning:, needed by /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/, may conflict with

ads gravatar image ads  ( 2012-05-18 07:53:01 -0600 )edit

Maybe libstdc++ could be cause the problem, but is needed by the mysql c++ connector. Could the solution be to upgrade to

ads gravatar image ads  ( 2012-05-18 07:54:52 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-05-18 09:24:17 -0600

ads gravatar image

updated 2012-05-18 09:25:06 -0600

My apologies, this issue is not related to ROS at all. Thanks for the attention.

For people experiencing the same problem:

The problem is that the generic Linux MySQL C++ connector is compiled using an older gcc. The solution is to install the red hat version and everything is fine.

Source: (refer to the bottom: [15 Sep 2010 22:54] aron curzon).

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-05-18 06:13:30 -0600

Seen: 1,387 times

Last updated: May 18 '12