[PATCH] Work around broken typeinfo with shared objects
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.
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?
Torsten Landschoff | Embedded software and FPGA development
nAmbition GmbH | Tatzberg 47, 01307 Dresden
| HRB NR. 23095 b. Amtsgericht Dresden
Managing director | Frank Pelzer
Re: [PATCH] Work around broken typeinfo with shared objects
> 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