[Bug 868] New: Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

Summary: Plugin loader loads duplicate libraries on Mac OS X
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: Mac OS X
Status: NEW
Severity: major
Priority: P3
Component: Real-Time Toolkit (RTT)
AssignedTo: orocos-dev [..] ...
ReportedBy: kiwi [dot] net [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

The library identification code can't handle the Mac versioned library naming
scheme, causing failed unit tests (and potentially incorrect runtime behaviour
in general)

Linux has the following, and RTT only loads the first library
- libfoo.so
- libfoo.so.1

Mac has the following, and RTT incorrectly loads both libraries (which means a
double load of libfoo.dylib, as the versioned entry is a symlnk to the
non-versioned library).
- libfoo.dylib
- libfoo.1.dylib

LINUX

0.051 [ Info   ][Logger] Loading plugin libraries from directory
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins
...
0.051 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so.2.4.0
...not a .so library: ignored.
0.051 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so.2.4.0
...not a .so library: ignored.
0.051 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so
...plugin
'/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so'
already loaded. Not reloading it.
0.051 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so
...plugin
'/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so'
already loaded. Not reloading it.


MAC OS X

0.000 [ Info   ][Logger] Loading plugin libraries from directory
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins
...
0.060 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.2.4.0.dylib
...Found library librtt-marshalling-macosx.2.4.0.dylib
0.060 [ Info   ][Logger] Loaded RTT Service 'marshalling' from
'rtt-marshalling-macosx.2.4.0'
0.061 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.dylib
...Found library librtt-marshalling-macosx.dylib
0.061 [ Info   ][Logger] Loaded RTT Service 'marshalling' from
'rtt-marshalling-macosx'
0.175 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.2.4.0.dylib
...Found library librtt-scripting-macosx.2.4.0.dylib
0.175 [ Info   ][Logger] Loaded RTT Service 'scripting' from
'rtt-scripting-macosx.2.4.0'
0.175 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.dylib
...Found library librtt-scripting-macosx.dylib
0.175 [ Info   ][Logger] Loaded RTT Service 'scripting' from
'rtt-scripting-macosx'


[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

--- Comment #7 from Peter Soetens <peter [..] ...> 2011-06-15 17:58:42 CEST ---
(In reply to comment #6)
> (In reply to comment #5)
> > Created attachment 706
> > Modified non-regex patch
>
> Thanks for digging on this. I've applied it to toolchain-2.4.
>
> Peter

There was a conflicting patch from Philippe Hamelin, but It looked like both
patches still work as intended. The other patch was for detecting the 'd'
suffix of libraries in order to pick the right one wrt _DEBUG builds.

Peter

[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED

--- Comment #6 from Peter Soetens <peter [..] ...> 2011-06-15 17:57:30 CEST ---
(In reply to comment #5)
> Created attachment 706
> Modified non-regex patch

Thanks for digging on this. I've applied it to toolchain-2.4.

Peter

[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

S Roderick <kiwi [dot] net [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Attachment #705 is|0 |1
obsolete| |

--- Comment #5 from S Roderick <kiwi [dot] net [..] ...> 2011-06-12 12:43:28 CEST ---
Created attachment 706
--> http://bugs.orocos.org/attachment.cgi?id=706
Modified non-regex patch

[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

S Roderick <kiwi [dot] net [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Attachment #696 is|0 |1
obsolete| |

--- Comment #4 from S Roderick <kiwi [dot] net [..] ...> 2011-06-12 00:52:07 CEST ---
Created attachment 705
--> http://bugs.orocos.org/attachment.cgi?id=705
Patch without regex dependancy

[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

--- Comment #3 from Peter Soetens <peter [..] ...> 2011-06-01 12:03:59 CEST ---
(In reply to comment #1)
> Created attachment 696
> Prevent Mac OS X from double loading dynamic libraries
>
> Refactor library identification logic
> Add unit test case for library names.
> NB Adds a dependancy for RTT on boost::regex
>
> WARNING the unit test case directly access internal PluginLoader functions. We
> might want to do this in a different fashion ...?
>
> Quite likely someone can come up with better regex's ...
>
> RESULTS - Linux (Ubuntu Lucid)
> &#10;&gt; 0.002 [ Info   ][Logger] Loading plugin libraries from directory&#10;&gt; ../rtt/./plugins ...&#10;&gt; 0.007 [ Debug  ][Logger] Scanning file&#10;&gt; ../rtt/./plugins/librtt-marshalling-gnulinux.so ...Found library&#10;&gt; librtt-marshalling-gnulinux.so&#10;&gt; 0.007 [ Info   ][Logger] Loaded RTT Service &#039;marshalling&#039; from&#10;&gt; &#039;rtt-marshalling-gnulinux&#039;&#10;&gt; 0.049 [ Debug  ][Logger] Scanning file&#10;&gt; ../rtt/./plugins/librtt-scripting-gnulinux.so ...Found library&#10;&gt; librtt-scripting-gnulinux.so&#10;&gt; 0.049 [ Info   ][Logger] Loaded RTT Service &#039;scripting&#039; from&#10;&gt; &#039;rtt-scripting-gnulinux&#039;&#10;&gt; 0.049 [ Debug  ][Logger] No such directory: ../../rtt/./plugins&#10;&gt; 0.049 [ Debug  ][Logger] No such directory:&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/./plugins&#10;&gt; 0.049 [ Info   ][Logger] Loading plugin libraries from directory&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins&#10;&gt; ...&#10;&gt; 0.049 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so.2.4.0&#10;&gt; ...not a .so library: ignored.&#10;&gt; 0.049 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so.2.4.0&#10;&gt; ...not a .so library: ignored.&#10;&gt; 0.049 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so&#10;&gt; ...plugin&#10;&gt; &#039;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so&#039;&#10;&gt; already loaded. Not reloading it.&#10;&gt; 0.049 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so&#10;&gt; ...plugin&#10;&gt; &#039;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so&#039;&#10;&gt; already loaded. Not reloading it.&#10;&gt;
>
> RESULTS - Mac OS X
> &#10;&gt; 0.001 [ Info   ][Logger] Loading plugin libraries from directory&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins&#10;&gt; ...&#10;&gt; 0.001 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.2.4.0.dylib&#10;&gt; ...not a .dylib library: ignored.&#10;&gt; 0.048 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.dylib&#10;&gt; ...Found library librtt-marshalling-macosx.dylib&#10;&gt; 0.048 [ Info   ][Logger] Loaded RTT Service &#039;marshalling&#039; from&#10;&gt; &#039;rtt-marshalling-macosx&#039;&#10;&gt; 0.048 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.2.4.0.dylib&#10;&gt; ...not a .dylib library: ignored.&#10;&gt; 0.114 [ Debug  ][Logger] Scanning file&#10;&gt; /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.dylib&#10;&gt; ...Found library librtt-scripting-macosx.dylib&#10;&gt; 0.114 [ Info   ][Logger] Loaded RTT Service &#039;scripting&#039; from&#10;&gt; &#039;rtt-scripting-macosx&#039;&#10;&gt;

Good fix, but I'm holding it off until we are sure it can't be done without
pulling boost::regex into the depency tree.

Or at least, we could use regex only on macosx builds...

Peter

[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Component|Real-Time Toolkit (RTT) |RTT
Version|rtt-trunk |unspecified
Product|RTT |Toolchain

--- Comment #2 from Peter Soetens <peter [..] ...> 2011-06-01 09:24:04 CEST ---
Moved to correct product.

[Bug 868] Plugin loader loads duplicate libraries on Mac OS X

http://bugs.orocos.org/show_bug.cgi?id=868

--- Comment #1 from S Roderick <kiwi [dot] net [..] ...> 2011-05-29 20:55:27 CEST ---
Created attachment 696
--> http://bugs.orocos.org/attachment.cgi?id=696
Prevent Mac OS X from double loading dynamic libraries

Refactor library identification logic
Add unit test case for library names.
NB Adds a dependancy for RTT on boost::regex

WARNING the unit test case directly access internal PluginLoader functions. We
might want to do this in a different fashion ...?

Quite likely someone can come up with better regex's ...

RESULTS - Linux (Ubuntu Lucid)
&#10;0.002 [ Info   ][Logger] Loading plugin libraries from directory&#10;../rtt/./plugins ...&#10;0.007 [ Debug  ][Logger] Scanning file&#10;../rtt/./plugins/librtt-marshalling-gnulinux.so ...Found library&#10;librtt-marshalling-gnulinux.so&#10;0.007 [ Info   ][Logger] Loaded RTT Service &#039;marshalling&#039; from&#10;&#039;rtt-marshalling-gnulinux&#039;&#10;0.049 [ Debug  ][Logger] Scanning file&#10;../rtt/./plugins/librtt-scripting-gnulinux.so ...Found library&#10;librtt-scripting-gnulinux.so&#10;0.049 [ Info   ][Logger] Loaded RTT Service &#039;scripting&#039; from&#10;&#039;rtt-scripting-gnulinux&#039;&#10;0.049 [ Debug  ][Logger] No such directory: ../../rtt/./plugins&#10;0.049 [ Debug  ][Logger] No such directory:&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/./plugins&#10;0.049 [ Info   ][Logger] Loading plugin libraries from directory&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins&#10;...&#10;0.049 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so.2.4.0&#10;...not a .so library: ignored.&#10;0.049 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so.2.4.0&#10;...not a .so library: ignored.&#10;0.049 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so&#10;...plugin&#10;&#039;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-marshalling-gnulinux.so&#039;&#10;already loaded. Not reloading it.&#10;0.049 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so&#10;...plugin&#10;&#039;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins/librtt-scripting-gnulinux.so&#039;&#10;already loaded. Not reloading it.&#10;

RESULTS - Mac OS X
&#10;0.001 [ Info   ][Logger] Loading plugin libraries from directory&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins&#10;...&#10;0.001 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.2.4.0.dylib&#10;...not a .dylib library: ignored.&#10;0.048 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.dylib&#10;...Found library librtt-marshalling-macosx.dylib&#10;0.048 [ Info   ][Logger] Loaded RTT Service &#039;marshalling&#039; from&#10;&#039;rtt-marshalling-macosx&#039;&#10;0.048 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.2.4.0.dylib&#10;...not a .dylib library: ignored.&#10;0.114 [ Debug  ][Logger] Scanning file&#10;/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.dylib&#10;...Found library librtt-scripting-macosx.dylib&#10;0.114 [ Info   ][Logger] Loaded RTT Service &#039;scripting&#039; from&#10;&#039;rtt-scripting-macosx&#039;&#10;