[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)
>

> 0.002 [ Info   ][Logger] Loading plugin libraries from directory
> ../rtt/./plugins ...
> 0.007 [ Debug  ][Logger] Scanning file
> ../rtt/./plugins/librtt-marshalling-gnulinux.so ...Found library
> librtt-marshalling-gnulinux.so
> 0.007 [ Info   ][Logger] Loaded RTT Service 'marshalling' from
> 'rtt-marshalling-gnulinux'
> 0.049 [ Debug  ][Logger] Scanning file
> ../rtt/./plugins/librtt-scripting-gnulinux.so ...Found library
> librtt-scripting-gnulinux.so
> 0.049 [ Info   ][Logger] Loaded RTT Service 'scripting' from
> 'rtt-scripting-gnulinux'
> 0.049 [ Debug  ][Logger] No such directory: ../../rtt/./plugins
> 0.049 [ Debug  ][Logger] No such directory:
> /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/./plugins
> 0.049 [ Info   ][Logger] Loading plugin libraries from directory
> /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins
> ...
> 0.049 [ 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.049 [ 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.049 [ 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.049 [ 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.
> 

>
> RESULTS - Mac OS X
>
> 0.001 [ Info   ][Logger] Loading plugin libraries from directory
> /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins
> ...
> 0.001 [ Debug  ][Logger] Scanning file
> /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.2.4.0.dylib
> ...not a .dylib library: ignored.
> 0.048 [ 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.048 [ Info   ][Logger] Loaded RTT Service 'marshalling' from
> 'rtt-marshalling-macosx'
> 0.048 [ Debug  ][Logger] Scanning file
> /opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.2.4.0.dylib
> ...not a .dylib library: ignored.
> 0.114 [ 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.114 [ Info   ][Logger] Loaded RTT Service 'scripting' from
> 'rtt-scripting-macosx'
> 

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)

0.002 [ Info   ][Logger] Loading plugin libraries from directory
../rtt/./plugins ...
0.007 [ Debug  ][Logger] Scanning file
../rtt/./plugins/librtt-marshalling-gnulinux.so ...Found library
librtt-marshalling-gnulinux.so
0.007 [ Info   ][Logger] Loaded RTT Service 'marshalling' from
'rtt-marshalling-gnulinux'
0.049 [ Debug  ][Logger] Scanning file
../rtt/./plugins/librtt-scripting-gnulinux.so ...Found library
librtt-scripting-gnulinux.so
0.049 [ Info   ][Logger] Loaded RTT Service 'scripting' from
'rtt-scripting-gnulinux'
0.049 [ Debug  ][Logger] No such directory: ../../rtt/./plugins
0.049 [ Debug  ][Logger] No such directory:
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/./plugins
0.049 [ Info   ][Logger] Loading plugin libraries from directory
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/gnulinux/./plugins
...
0.049 [ 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.049 [ 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.049 [ 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.049 [ 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.

RESULTS - Mac OS X

0.001 [ Info   ][Logger] Loading plugin libraries from directory
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins
...
0.001 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-marshalling-macosx.2.4.0.dylib
...not a .dylib library: ignored.
0.048 [ 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.048 [ Info   ][Logger] Loaded RTT Service 'marshalling' from
'rtt-marshalling-macosx'
0.048 [ Debug  ][Logger] Scanning file
/opt/sw/orocos/toolchain-next/build/rtt/../../install/lib/orocos/macosx/./plugins/librtt-scripting-macosx.2.4.0.dylib
...not a .dylib library: ignored.
0.114 [ 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.114 [ Info   ][Logger] Loaded RTT Service 'scripting' from
'rtt-scripting-macosx'