[PATCH] Work around broken typeinfo with shared objects

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Work around broken typeinfo with shared objects

Torsten Landschoff
Hi *,

This is yet another patch which works around Micro-Manager not working
correctly on current Linux.

The issue that this patch solves or rather works around is the broken
run time type information in the usage context of micro manager.

It manifests itself in that I can't use streaming image acquisition
(tested against configuration MMConfig_Stream.cfg). The circumstances
leading to this breakage are:
* MMCoreJ_wrap.so is loaded with dlopen option RTLD_LOCAL (don't export
symbols for other dlopen)
* MMCoreJ_wrap.so uses dlopen to load the device driver

As symbols are not shared, both libraries get their own typeinfo
instances for identical types. The result is that
dynamic_cast<MetadataSingleTag*> returns 0 as well as
dynamic_cast<MetadataArrayTag*> on the same instance if this instance
was created in the other shared library.

The issue is explained here: http://gcc.gnu.org/faq.html#dso

Unfortunately, the solution suggested there (use RTLD_GLOBAL) does not
help (needs changes to the JVM and results in name clashes when loading
device adapters). I am also against using the global namespace here.

The work around I used it to replace dynamic_cast with virtual methods
(which does still work even though the "wrong" virtual method table can
be used). A better solution would be to use virtual methods for the
serialization code as well (I think the Dump method essentially does the
same as Serialize() for MetadataTag).

What do you think?

Greetings, Torsten

--
Torsten Landschoff | Embedded software and FPGA development
nAmbition GmbH     | Tatzberg 47, 01307 Dresden
                   | HRB NR. 23095 b. Amtsgericht Dresden
Managing director  | Frank Pelzer


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

dynamic_cast_workaround.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Work around broken typeinfo with shared objects

Nico Stuurman-4
Hi Torsten,

> This is yet another patch which works around Micro-Manager not working
> correctly on current Linux.

> The issue that this patch solves or rather works around is the broken
> run time type information in the usage context of micro manager.

Thanks for the description of the problem and the patch.  I could  
confirm the issue under Ubuntu 8.0.4, and your explanation seems very  
reasonable.  This code works on the Mac, I guess that the RTTI  
typeinfo is handled differently on that platform..

Regretfully, I failed to apply the patch.  I'll send you the reject  
file off-list.

Best,

Nico


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general