ratt-ru / meqtrees

A library for implementing radio astronomical Measurement Equations
http://meqtrees.net
10 stars 2 forks source link

Timba.parmtables module breaks if imported before Timba.dmi #820

Open gijzelaerr opened 10 years ago

gijzelaerr commented 10 years ago
at 2011-09-15 02:46:58 Oleg Smirnov reported:

Timba.parmtables module breaks if imported before Timba.dmi

gijzelaerr commented 10 years ago

Original comment thread migrated from bugzilla

at 2011-09-15 02:46:58 Oleg Smirnov replied:

Due to some silliness w.r.t. dynamic libs,the parmtables module becomes non- functional if imported first. A call to e.g. domain_list() throws an exception, which can be traced back to pyFromRecord() calling createPyObject() with a null basetype (which ought to be py_dmisyms.record, so obviously this symbol is not filled in). This is most likely because parmtables.so pulls in its own copy of octopython.so, before the sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) in Timba.dmi. Recall that the latter call is required for octopython.so to initialize properly (we must have only one shared copy of this .so, which the flags ensure).

For now, I have worked around this problem by changing the order of the import statements in ParmTab.py, but I'm opening the bug because a more fundamental fix is required after R1.2. If the .so linking problems cannot be worked around, then as a minimum, parmtables should check that Timba.dmi is already imported, and return an error explaining the problem if it isn't.

Note that these dl flags are probably responsible for some packages falling over if imported into MeqTrees "late". I had been working around this by importing them in "early" -- see top of OCTOPython/src/init.py for a list of import statements. Perhaps if only octopython.so requires thse dl flags, I should warp the import of octopython with some code that restores the flags after the import is done?