The directory /opt/www/bruyninckxh2/web/tmp/drutex-bb8e91aa7f86a5a7c1164bfcedea4a4f-1 has been created.

[Bug 402] New: Mixing liborocos-rtt.a and .so causes crash upon exit

For more information about this bug, visit
A new bug was added:
Summary: Mixing liborocos-rtt.a and .so causes crash upon exit
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: Build System
AssignedTo: orocos-dev [..] ...
ReportedBy: peter [dot] soetens [..] ...

When the RTT is compiled as a static library and a dependent library (like OCL)
is compiled as a .so, an executable which uses these libraries will crash upon
exit, while the same application using all-so won't:

$ valgrind ./deployer
==25523== Memcheck, a memory error detector.
==25523== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==25523== Using LibVEX rev 1658, a library for dynamic binary translation.
==25523== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==25523== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation
framework.
==25523== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==25523== For more details, rerun with: -v
==25523==
Switched to : Deployer

This console reader allows you to browse and manipulate TaskContexts.
You can type in a command, event, method, expression or change variables.
(type 'help' for instructions)
TAB completion and HISTORY is available ('bash' like)

In Task Deployer. (Status of last Command : none )
(type 'ls' for context info) :quit

==25523== Invalid read of size 4
==25523== at 0x4EDF0B9: __gnu_cxx::__exchange_and_add(int volatile*, int)
(in /usr/lib/libstdc++.so.6.0.8)
==25523== by 0x474B2C0: __tcf_6 (in
/home/sspr/src/Orocos/trunk/ocl/build.a/deployment/liborocos-deployment.so.0.3.0)
==25523== by 0x4F78CC8: __cxa_finalize (in /lib/tls/i686/cmov/libc-2.5.so)
==25523== by 0x46F8FF2: (within
/home/sspr/src/Orocos/trunk/ocl/build.a/deployment/liborocos-deployment.so.0.3.0)
==25523== by 0x48F354B: (within
/home/sspr/src/Orocos/trunk/ocl/build.a/deployment/liborocos-deployment.so.0.3.0)
==25523== by 0x400D9ED: (within /lib/ld-2.5.so)
==25523== by 0x4F789D8: exit (in /lib/tls/i686/cmov/libc-2.5.so)
==25523== by 0x4F61EC3: (below main) (in /lib/tls/i686/cmov/libc-2.5.so)
==25523== Address 0x5B67338 is 8 bytes inside a block of size 17 free'd
==25523== at 0x4020F51: operator delete(void*) (vg_replace_malloc.c:244)
==25523== by 0x4EC0A5C: std::string::_Rep::_M_destroy(std::allocator
const&) (in /usr/lib/libstdc++.so.6.0.8)
==25523== by 0x428B933: __tcf_6 (in
/home/sspr/src/Orocos/trunk/ocl/build.a/taskbrowser/liborocos-taskbrowser.so.0.3.0)
==25523== by 0x4F78CC8: __cxa_finalize (in /lib/tls/i686/cmov/libc-2.5.so)
==25523== by 0x4262D22: (within
/home/sspr/src/Orocos/trunk/ocl/build.a/taskbrowser/liborocos-taskbrowser.so.0.3.0)
==25523== by 0x443C0AB: (within
/home/sspr/src/Orocos/trunk/ocl/build.a/taskbrowser/liborocos-taskbrowser.so.0.3.0)
==25523== by 0x400D9ED: (within /lib/ld-2.5.so)
==25523== by 0x4F789D8: exit (in /lib/tls/i686/cmov/libc-2.5.so)
==25523== by 0x4F61EC3: (below main) (in /lib/tls/i686/cmov/libc-2.5.so)
==25523==
==25523== Invalid free() / delete / delete[]
==25523== at 0x4020F51: operator delete(void*) (vg_replace_malloc.c:244)
==25523== by 0x4EC0A5C: std::string::_Rep::_M_destroy(std::allocator
const&) (in /usr/lib/libstdc++.so.6.0.8)
==25523== by 0x474B2D3: __tcf_6 (in
/home/sspr/src/Orocos/trunk/ocl/build.a/deployment/liborocos-deployment.so.0.3.0)
==25523== by 0x4F78CC8: __cxa_finalize (in /lib/tls/i686/cmov/libc-2.5.so)

....

I don't know if this is a linker problem, an Orocos problem or expected
behaviour.

[Bug 402] Mixing liborocos-rtt.a and .so causes crash upon exit

For more information about this bug, visit
A comment was added:
------- Comment #3 from peter [dot] soetens [..] ... 2007-05-15 10:10

(In reply to comment #2)
> (In reply to comment #0)
> > When the RTT is compiled as a static library and a dependent library (like OCL)
> > is compiled as a .so, an executable which uses these libraries will crash upon
> > exit, while the same application using all-so won't:
> >
> > $ valgrind ./deployer
>
> What does ldd ./deployer report exactly?

$ ldd ./deployer
linux-gate.so.1 => (0xffffe000)
libcomedi-0.7.22.so => /usr/local/lib/libcomedi-0.7.22.so (0xb7f21000)
liborocos-taskbrowser.so.0.3.0 =>
/home/sspr/src/Orocos/trunk/ocl/build.a/taskbrowser/liborocos-taskbrowser.so.0.3.0
(0xb7a75000)
liborocos-deployment.so.0.3.0 =>
/home/sspr/src/Orocos/trunk/ocl/build.a/deployment/liborocos-deployment.so.0.3.0
(0xb75af000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7578000)
libxerces-c.so.27 => /usr/lib/libxerces-c.so.27 (0xb7197000)
libncurses.so.5 => /lib/libncurses.so.5 (0xb7154000)
libreadline.so.5 => /lib/libreadline.so.5 (0xb7122000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7038000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7011000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7005000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb6ec4000)
/lib/ld-linux.so.2 (0xb7f2e000)
libicuuc.so.36 => /usr/lib/libicuuc.so.36 (0xb6da4000)
libicudata.so.36 => /usr/lib/libicudata.so.36 (0xb63f4000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb63f0000)

All libs dynamic (also OCL!) except orocos-rtt

>
> > ==25523== Invalid read of size 4
> > ==25523== at 0x4EDF0B9: __gnu_cxx::__exchange_and_add(int volatile*, int)
> > (in /usr/lib/libstdc++.so.6.0.8)
> > ==25523== by 0x474B2C0: __tcf_6 (in
>
> > I don't know if this is a linker problem, an Orocos problem or expected
> > behaviour.
>
> Does this also occur if the default libraries such as libstdc++ are linked in
> statically instead?

I don't think this is an issue, as when the OCL is linked statically, the
problem disappears.

[Bug 402] Mixing liborocos-rtt.a and .so causes crash upon exit

For more information about this bug, visit
A comment was added:
------- Comment #2 from klaas [dot] gadeyne [..] ... 2007-05-14 16:48

(In reply to comment #0)
> When the RTT is compiled as a static library and a dependent library (like OCL)
> is compiled as a .so, an executable which uses these libraries will crash upon
> exit, while the same application using all-so won't:
>
> $ valgrind ./deployer

What does ldd ./deployer report exactly?

> ==25523== Invalid read of size 4
> ==25523== at 0x4EDF0B9: __gnu_cxx::__exchange_and_add(int volatile*, int)
> (in /usr/lib/libstdc++.so.6.0.8)
> ==25523== by 0x474B2C0: __tcf_6 (in

> I don't know if this is a linker problem, an Orocos problem or expected
> behaviour.

Does this also occur if the default libraries such as libstdc++ are linked in
statically instead?

Ruben Smits's picture

[Bug 402] Mixing liborocos-rtt.a and .so causes crash upon exit

For more information about this bug, visit
A comment was added:
------- Comment #1 from ruben [dot] smits [..] ... 2007-05-14 16:14

I've seen this kinds of problems before, at the time we began to use cmake,
components were standardly build as shared libraries resulting in the same kind
of problems when linked with a static rtt-lib.

I've no idea though what could cause the problem.

Ruben