Open hroest opened 5 years ago
Sounds like an auditwheel issue, so CC @ehashman.
To confirm:
After running auditwheel, you get a manylinux wheel that's broken. When you try to import it, it says: libQt5Core-82077f0c.so.5.9.4: undefined symbol: stderr, version 6
Then, you unpack the broken wheel, and do:
cp -f /qt/lib/libQt5Core.so.5.9.4 .../pyopenms/.libs/libQt5Core-82077f0c.so.5.9.4
And after this, it now can import regularly?
IIRC the only change we make to the .so files when vendoring them is to use patchelf to change the soname. (Elana, do I remember correctly?) I haven't heard of any bugs here recently, but patchelf is kind of black magic so it's plausible...
For context: .so files have two names. There's the actual name of the file on the disk. And then embedded inside the file, there's a string saying what the file thinks its name is supposed to be. Normally, these two names are supposed to be the same.
When we use cp
to rename the file, that changes the name on disk. But it doesn't change the string embedded inside the file. When auditwheel copies the file, it tries to change both. So it sounds like something is going wrong with the change-the-embedded-file-name step.
The reason this matters is: well, if you're only using one package, it doesn't matter. The embedded name string doesn't do anything; only the filename is used. But if you have multiple packages, that each have their own copies of Qt, then the loader will sometimes be like "oh hey, this package is asking for the system libQt5Core, but I don't need to go find that, because i know I already loaded a libQt5Core earlier! I'll just use the one I already loaded". This check uses the name embedded in the file. So if we don't fix up the embedded name, it can cause obscure crashes later, only in certain complex configurations, when another package entirely accidentally ends up using your package's copy of libQt5Core.
Thanks for the cc @njsmith, is it possible to move this issue to the auditwheel repo?
I have no idea. I've seen github offering to let me move issues recently, but that bit of UI seems to be missing on this issue. It's mysterious to me.
I'm not a manylinux admin so I can't transfer it :( @dstufft can you please move this issue to auditwheel?
And after this, it now can import regularly?
yes, that is correct.
IIRC the only change we make to the .so files when vendoring them is to use patchelf to change the soname. (Elana, do I remember correctly?) I haven't heard of any bugs here recently, but patchelf is kind of black magic so it's plausible...
I agree with the black magic part, but if I look at the file sizes it seems that more is going on than just changing the soname:
# ls -tlrh /qt/lib/libQt5Core.so.5.9.4
-rwxr-xr-x 1 root root 5.9M Nov 27 18:00 /qt/lib/libQt5Core.so.5.9.4
# ls -tlrh /tmp/libQt5Core-82077f0c.so.5.9.4
-rwxr-xr-x 1 root root 6.2M Nov 30 16:25 /tmp/libQt5Core-82077f0c.so.5.9.4
so there is an additional 300kb in the file after patching it, so there must be quite a bit of things that got changed.
When we use
cp
to rename the file, that changes the name on disk. But it doesn't change the string embedded inside the file. When auditwheel copies the file, it tries to change both. So it sounds like something is going wrong with the change-the-embedded-file-name step.
Is there a way for me to see the exact command that auditwheel is issuing so that I can try and reproduce what it is doing?
there is an additional 300kb in the file after patching it, so there must be quite a bit of things that got changed.
This doesn't necessarily indicate much. ELF binaries aren't designed to make in-place editing easy, so sometimes the easiest way for patchelf to do its work is to copy a large chunk while just modifying a small part.
If you want to dig into this, readelf
is a useful tool.
I wonder if this was due to a bug in patchelf
. @hroest can you still reproduce this?
Issue
We have found that
auditwheel repair
processes some of our shared objects such that they are broken after processing. After processing a wheel built withand installing the resulting wheel, the python package is broken:
Workaround
Our current workaround is to unpack the wheel and replace the
libQt5Core.so
library in the.libs
folder manually with the system one in "/qt/lib/libQt5Core.so.5.9.4" which works for now. Similarly, if you replace the above library with the one used during the build, it works:curiously, the library is actually larger after processing with auditwheel.
Reproducing the issue
You can reproduce the issue using the following script https://github.com/OpenMS/OpenMS/blob/feature/py_release/src/pyOpenMS/dist-scripts/create-manylinux.sh - note that our build takes a while
Debug information
Image
We use the following image:
Show