-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Platform detection is wrong on x32 #4962
Comments
I have little clue about what happens here. Maybe some other @pypa/pip-committers knows. |
Not me... |
One way to reproduce this would be to use i386 Debian with the amd64 kernel. Let me know if you'd like anything specifically run in this environment. |
Can you demonstrate a specific pip command line invocation that does the wrong thing on that platform? I imagine that would help someone with the relevant understanding of the code to debug the issue. |
If there's a Linux platform mode other than i686 and x86_64, CPython core dev doesn't know anything about it either. |
I think you mean x32 Debian. i386 Debian does the "right" thing here. |
You can see the problem in action here on a Debian system (needs a kernel booted with
The import fails because pip downloaded and installed an i686 wheel, so the shared object is of the wrong arch/ABI:
If you force a source installation, then it works:
But note that pip would have built and cached a wheel tagged "i686" that contains x32 shared objects if binaries weren't disabled, so this wheel would not work on an actual i686 system. |
I was able to reproduce this bug and I think I have a working patch. Let me attempt to explain what's going on here. pip/src/pip/_internal/pep425tags.py Lines 134 to 138 in f038fe4
In L134, we use There are three Linux ABIs that I am aware of: "linux_x86_64" (64-bit), "linux_i686" (32-bit), "linux_x32" (another flavour of 32-bit ABI). Lines 135-138 are intended to handle the unusual but possible case in which you have a 64-bit kernel but are running 32-bit binaries in userspace. The code assumes that if this happens, the user must be using the 32-bit "linux_i686" ABI. However, as @mithrandi reports, this assumption is incorrect. We could have compiled userspace against the "linux_x32" ABI instead. When that's the case, we get a platform mismatch of "linux_i686" on a machine with the "linux_x32" ABI. Hence, when we download a dependency that doesn't have pure wheels, pip will incorrectly fetch i686 wheels where they're available: note that Since we're using the x32 ABI, the i686 ELF interpreter isn't available, so when we try to run the wheels, the system barfs. This is why we get an I determined that |
Patch seems to work! Here's the output on the x32 schroot:
This is great! We got the pure wheel and compilation failed because I lack the dev headers :) On i686:
We still get the correct wheels! So I'm pretty convinced this worked, and it shouldn't break anything else as the only logic affected is inside that |
Ah, whoops, ignore me :) |
Closing this, since pypa/packaging#217 covers this now. |
pip/src/pip/_internal/pep425tags.py
Lines 135 to 138 in f038fe4
This code assumes that i686 is the only way to have 32-bit pointers on x86_64, but the x32 ABI is another way for this to happen, and i686 binaries won't work on x32.
The text was updated successfully, but these errors were encountered: