-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Move dlopenflags handling into new library loader #247
Conversation
Right. Thanks.
I think we have to go one step further, though, and apply the flags to all version modules. We can do that in the module __getattr__ function, by letting it do the imports explicitly.
A context manager for the flag setting might also be a good idea, both for internal reuse and also exposed for users with special needs.
|
By doing it in I, personally, don't use I think the idea of moving it to a context processor for users with special needs seems decent. |
Something I'd really like to do is have a test case for this behaviour. |
1beff57
to
74da7d3
Compare
OH. I misunderstood... |
So I was trying to produce a local test case for dynamic linking with multiple lua versions available via
|
I updated the implementation in the master branch to make an explicit import in |
74da7d3
to
99afcfa
Compare
I've done this now. It's worth noting that if I understand the import mechanism correctly this won't work if someone does:
I suspect that in that case they'd have to use the context manager themselves... |
@scoder what's going on with the CI runs? |
I think we have to enable |
The
It's not released yet. I'll try to get this PR in first. |
99afcfa
to
6fdb131
Compare
@scoder I suspect that we can't eagerly globally load lots of different lua runtimes because they will have conflicting symbol names. |
Hmm. That sounds reasonable – and annoying. Then … maybe we need to leave the usage of the context manager really to the users? Let them apply it where they need it, and leave it out everywhere else? The need to load a Lua binary module probably isn't very widespread. We could still consider keeping it for the default module loading, i.e. when you just do |
macOS works fine, apparently, but the tests crash on Linux with Python 3.x (2.7 is ok as well, it seems). I couldn't reproduce this locally yet. |
Linux with 3.x is my use case. Specifically im running alpine with musl but I've also tested with glibc locally
I saw the test logs but didnt try to reproduce yet myself either.
-------- Original Message --------
…On 11 Oct 2023, 10:15, scoder wrote:
dlopen() is not available on Windows. I fixed that by disabling the flag setting there.
macOS works fine, apparently, but the tests crash on Linux with Python 3.x (2.7 is ok as well, it seems). I couldn't reproduce this locally yet.
—
Reply to this email directly, [view it on GitHub](#247 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAO7PIQCMMUCIWT5MUJRURLX6ZPTRANCNFSM6AAAAAA5XIGE5U).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Triggering a fresh CI run against latest master. |
You're right that symbols seem to get mixed up. Here's a local session, now that I got DLL loading working on my machine.
Note that |
So, back to my proposal in #247 (comment) |
My only comment is that at present the only people who can load dynamically linked modules at all are those using nonbundled Lua and those people will not have multiple runtimes available.
Can we detect that scenario and autoconfigure if its the case?
-------- Original Message --------
…On 12 Oct 2023, 10:52, scoder wrote:
So, back to my proposal in [#247 (comment)](#247 (comment))
—
Reply to this email directly, [view it on GitHub](#247 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAO7PIW6PYU3NXXSMF6DDTLX664XNANCNFSM6AAAAAA5XIGE5U).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
The C library is no longer dynamically loaded directly when `_lupa` is imported, so we need to move the special handling of dlopenflags into the `_import_newest_lib()` function in order to ensure they are set when the lupa C extension is `dlopen`'d. We also expose a context manager `eager_global_linking()` for users with special needs to get the same behaviour.
This was previously handled by a plain try-except at module level.
Co-authored-by: scoder <[email protected]>
6d439b4
to
5a64885
Compare
Enabling module loading by default doesn't work when there are multiple Lua modules because the symbols collide with each other when loaded with RTLD_GLOBAL. Make the default use of the dlopenflags conditional on there only being one available Lua module.
5a64885
to
6d1e877
Compare
@scoder I've pushed up an attempt to do this. I don't know if it's going to pass CI and it seems that it's blocked behind your approval to execute. Certainly this commit works in the CI for my application, but that's very narrow in terms of platform/setup in that it runs a single Python version with a single version of system Lua |
Ok, then let's keep it like this. @riconnon, could you write up some documentation for this in the readme? It seems worth explaining, also more generally why this is an issue that users need to take control of. |
The C library is no longer dynamically loaded directly when _lupa is imported, so we need to move the special handling of dlopenflags into the _import_newest_lib() function in order to ensure they are set when the lupa C extension is dlopened.
Closes #246