-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc and cargo binaries crash on startup on ARM with glibc, because libpthread is loaded too late #35843
rustc and cargo binaries crash on startup on ARM with glibc, because libpthread is loaded too late #35843
Comments
all of this happens before main is even called, this is entirely glibc shooting itself in the foot
|
Which glibc version is needed to be built against for this crash to happen? I never had this problem but others sure did: You could probably find out the difference if you used one of my uploads. |
Are we sure its pthread and not
? |
@nagisa It would be very interesting if it was that, but I've seen that all the time when using |
@nagisa Yes, I'm fairly certain it's glibc / pthread. Take a look at the linked glibc bugzilla page, and note how it crashes in the same function, doing the same things. Removing the DT_NEEDED entry again with patchelf brings the problem back, while leaving the kernel bug workaround in place. |
whoops, seems I didn't post my useful gdb logs, and assumed I'd already posted them for all to read.
|
Oh, so yeah, buildbot, as always, uses quite old versions of glibc and binutils/gcc. I’m more inclined to blame this bug on old version of binutils used on buildbot, but it is very possible glibc may also be a cause, especially given it provides no forward stability guarantees whatsoever. The jump to NULL from PLT is one of the more prevalent reasons of library version mismatches, too, though the fact that loading the pthread earlier fixes this makes this sentence irrelevant. |
This is before main hits, it's glibc initialisation. The underlying bug exists in just about any version of glibc from the past decade, and no code outside glibc is invoked the entire time. |
The
However the workaround above (when applied to cargo) does not fix this. edit: should have read my own backtrace, running |
@ghost Awesome! I hadn't gotten cargo working yet, so I'm very glad you've figured this out ❤️ |
Just for clarity, I also ran the previous edit: nvm, I see that it worked for you. |
@ghost I tested both with and without the pthread patchelf, but cargo already has libpthread in its DT_NEEDED, and the duplicate entry doesn't seem to be necessary. I'm now happily porting things of my own to ARM [= |
Any idea if #35982 could be related? |
(a) Does this effectively mean that our binary releases of rustc for ARM crash everywhere? Or is it just on systems with newer glibc? (b) Is there any workaround for this? Perhaps compiling against glibc-2.19 or doing the patchelf trick on the buildbots. Would rustc still work on systems with older glibcs if patched like that? |
@japaric |
Thanks, I'd be very helpful if you can. I think we should test Debian Wheezy (2.13), Ubuntu Precise (2.15), Ubuntu Trusty (2.19) and perhaps Raspbian (is that Debian Wheezy based?). In theory we support glibc-2.14 and newer so it's okay if Wheezy doesn't work.
Ah, I forgot to ask: can the patchelf trick used on a x86_64 host to patch the arm binary? (we produce our arm binaries via cross compilation) I've only tested patching the binary on the ARM host itself. |
@japaric patchelf cares not for the target, it just manipulates ELF files. |
Trying the
but the
Could I be missing some other package/command? |
@japaric: I think |
if I use the path where libpthread.so.0 resides on the target ARM device, which is not where libpthread lives on the x86_64 host.
if I instead use the path where libpthread resides on the host:
😕 |
😕 So much for helpful error messages... Then maybe it needs an absolute path to You can also try running with strace, something like |
should work indeed. |
lol Ubuntu 16.04 ships with patchelf 0.8 and that version doesn't have the --add-needed command:
I have patchelf 0.9 on the ARM device. Which does have the --add-needed flag:
I'll compile a newer patchelf from source on the Ubuntu docker container I'm using and try that newer version. Thanks for the help @TimNN and @sanmai-NL |
OK, using patchelf 0.9, I can fix @alexcrichton How do you feel about that ^ "fix"? Alternatively, we could explore bumping the glibc version (2.19 appears to produce working binaries) that we use in the buildbots. We are currently using glibc-2.14 to support systems with (very) old glibcs but, right now, our binaries segfault on systems with recent glibcs because of this bug. |
@japaric: Bump the glibc dep please. Working around an issue in known flawed, old software seems less preferable to me. |
Using a glibc-2.16/gcc-4.9 cross toolchain I can produce good rustc binaries. That seems like the smallest bump we can make because I can't get crosstool-ng to produce a glibc-2.15/gcc-4.9 toolchain. |
@japaric I'd prefer to bump the glibc dep, but I've seen you've done that, so I'll merge! |
related: https://sourceware.org/bugzilla/show_bug.cgi?id=16628
workaround:
I'm not sure why rustc works at all on x86.
The text was updated successfully, but these errors were encountered: