Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

Crash of python when exiting the interface ("python: double free or corruption") #7

Open
francois-keith opened this issue Feb 11, 2014 · 1 comment

Comments

@francois-keith
Copy link
Contributor

Hello all,

Since the merge #4, there is a problem at the destruction of the python interface used to interact with the SoT in some cases.

To reproduce the error, create the file test.py with the following content:

from dynamic_graph.sot.core.matrix_util import matrixToTuple
from dynamic_graph.sot.dynamics.angle_estimator  import AngleEstimator

Running python ./test.py
Returns the following error:

*** glibc detected *** python: double free or corruption (fasttop): 0x00000000028b5870 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f964559db96]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSsD1Ev+0x1f)[0x7f96433f751f]
/lib/x86_64-linux-gnu/libc.so.6(+0x3b901)[0x7f964555a901]
/lib/x86_64-linux-gnu/libc.so.6(+0x3b985)[0x7f964555a985]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf4)[0x7f9645540774]
python[0x41bb31]
======= Memory map: ========
00400000-00670000 r-xp 00000000 08:06 4066903                            /usr/bin/python2.7
00870000-00871000 r--p 00270000 08:06 4066903                            /usr/bin/python2.7
00871000-008da000 rw-p 00271000 08:06 4066903                            /usr/bin/python2.7
008da000-008ec000 rw-p 00000000 00:00 0 
00951000-0100d000 rw-p 00000000 00:00 0                                  [heap]
...
(then there is the list of loaded libraries.)

This crash occurs because the library libsot-dynamic.so is loaded after the library libsot-core.so.
At the opposite, the following code will properly exit:

from dynamic_graph.sot.dynamics.angle_estimator  import AngleEstimator
from dynamic_graph.sot.core.matrix_util import matrixToTuple

Note that this is only due to the fact that in dynamic_graph/sot/dynamics/__init__.py, the Dynamic entity is the first one loaded. With this

from angle_estimator import AngleEstimator
from dynamic import Dynamic

the test would also crash.

Is there a way to correct this?
For now, I have to use a workaround that consists in systematically importing

from dynamic_graph.sot.dynamics.dynamic import Dynamic

first, so as to avoid this issue.

@florent-lamiraux
Copy link
Member

Hello François,

Some of us noticed the issue. I tried to track the error with valgrind but without success. According to valgrind, there is a double free error in the destructor of std::string, but I have been unable to find which string is the source of the problem. Your experimentation above is another interesting clue. Mehdi suggested to compile python with -g flag and to reproduce the error in gdb.

We need to investigate further.

Florent

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants