New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python modules not linking to libpython causes issues for RTLD_LOCAL system-wide #80934
Comments
Most affected platforms: RedHat and Debian, but with the changes from bpo-21536 probably all Linux distributions will be affected. bpo-34814 and bpo-21536 and https://bugzilla.redhat.com/show_bug.cgi?id=1585201 make statements along the lines of "In short, RTLD_LOCAL is not supported." As a developer generally cannot really know if some library might ever pull in a most indirect reference to libpython, not supporting RTLD_LOCAL in Python essentially means RTLD_LOCAL can NEVER EVER be used safely. A test-case that will fail the import command when modules have not been linked against libpython is attached (demonstrating only one layer of indirection, but much more complex cases are of course possible). While dlmopen is an alternative with similar behaviour to RTLD_LOCAL on recent Linux versions for this case, it is not portable. |
why is this an issue on Debian? Debian is already not linking with libpython. |
The modules not linking against libpython CAUSES this issue, thus Debian being affected even for old Python versions before bpo-21536. |
I'd like to mention a real-world example for this issue: syslog-ng with its Plugins are loaded using dlopen() after the initial plugin discovery. RTLD_LOCAL Since we have Python-based plugins, we had to use RTLD_GLOBAL instead (with RTLD_LAZY to Note: The latest Python 3 version seems to be working with RTLD_LOCAL as everything |
In the What's New section of 3.8 (https://docs.python.org/3.8/whatsnew/3.8.html#changes-in-the-c-api) it indicates that:
So if you are embedding python by dlopen'ing libpython.so you should use RTLD_GLOBAL to make sure everyone is using the same symbols. You have more information on the rationale and decisions in bpo-21536. Is your use-case not cover by the arguments in bpo-21536? What is the problem of embedding by dlopening libpython using RTLD_GLOBAL? |
I'm not sure how I can explain it much better, I even wrote example code after all, but I'll try...
Neither me nor Laszlo are using/embedding or otherwise involving Python (directly/intentionally at least). Just to try be very clear: We are not users of libpython, we do not write or use any python code ourselves (except through indirect dependencies) and we are still hit by this issue. |
I guess one way this could be "solved" would be by libpython doing a dlopen on itself with RTLD_GLOBAL on Python initialization. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: