[Python-Dev] Problems with Python's default dlopen flags

Ralf W. Grosse-Kunstleve rwgk@cci.lbl.gov
Sun, 5 May 2002 12:45:13 -0700 (PDT)


> > Unfortunately, the only reproducible case we have is not exactly small.
> > However, we can give anyone interested full access to the machine and
> > test case where it's occurring [details appended at the bottom of this
> > message].

That message is referring to a slightly different situation:
I am using a statically linked libboost_python.a.

When I wrote the message that David attached I only had a very
complex example. Now I have a significantly simpler one, and this
is what I think is happening:

    python -> dlopen ext1.so with statically linked libboost_python.a
    python -> dlopen ext2.so with statically linked libboost_python.a
    obj1 = ext1.a_type()
    obj1 has a member function which will dispatch to one
      of two alternative C++ function. In the course of
      resolving which C++ function to use an exception is
      raised in ext2.so that is meant to be caught in ext1.so.
    If both extension modules are imported with RTLD_LOCAL
    the exception is not caught correctly. However, when
    using RTLD_GLOBAL this works properly.

Considering the discussion in this thread it is now pretty clear
that this behavior is expected.

So... I have just done the step that I should apparently have done
months ago (this is for how long the problem is bugging me):
Compiling our extension modules against a libboost_python.so.
With that my example works even without changing setdlopenflags.

I am obviously learning the hard way here. At least things
are starting to make sense now. And it seems as if RTLD_LOCAL
will work for a shared Boost.Python library.

Thanks for sharing your valuable knowledge about dynamic linking.

Ralf