-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
println! segfaults with nightly-2018-06-24 on macOS 10.10 #51758
Comments
Could possibly be #50586? |
Can't repro on 10.13. Could you use |
Based on reading surrounding assembly, #[thread_local]
static __KEY: $crate::thread::__FastLocalKeyInner<$t> = …; So yeah, thread locals on old macOS suggest the same underlying issue as #50867 and possibly #50586. |
|
To try and reduce further, the code below is somewhat similar to part of Is there an LLVM bug to open about reducing that assumption? use std::cell::RefCell;
use std::io::Write;
thread_local! {
static FOO: RefCell<Option<Box<Write>>> = RefCell::new(None);
}
pub fn foo() -> bool {
FOO.with(|c| c.borrow().is_some())
} movq __ZN1a3FOO7__getit5__KEY17h0d854c627114cb56E@TLVP(%rip), %rdi
callq *(%rdi)
movdqa 16(%rax), %xmm0
|
Hi, I've also run into this... Is there a good workaround? I read somewhere that enabling LTO will solve the problem, but I'm guessing that will increase compile times significantly. |
An arguably better workaround is to build on macOS 10.11 / XCode 8, or more recent. (That built program should still be able to run on some earlier OS versions.) But of course that can be more involved than flipping an LTO switch. |
Ok, I was under the impression that XCode 8 and later doesn't support OSX 10.11. I just tried installing the Xcode 8.3 command line tools, but the installer refuses to go ahead, saying it needs 10.12. Has anyone been able to make this work on 10.11 by upgrading XCode? |
Per wikipedia, XCode 8.2.1 runs on macOS 10.11.5. |
Is it possible to test this with Xcode 9.3? Given how many times this TLS problem appears it is worth adding the test case to CI, however can't just switch our CI images back to Xcode 7 as that would be too slow for normal tests. |
Per #50867 (comment) the root cause is a bug in XCode which is fixed in XCode 8. I think that the two realistic outcomes are:
|
XCode 8.2.1 is listed as running on 10.11.5, but does only include OS X SDK version 10.12.2, so I would be reluctant to remove 7.3 and install 8.2.1 if I wanted to keep using xcode to build for 10.11. Anyway, what just worked for me on 10.11 is to install the XCode 8.2 Command Line Tools (CLT) only, downloaded from here:
(you may need an apple dev account) Running the installer will keep the current CLT installation and install the new one in /Library/Developer/CommandLineTools/ I then ran:
After this, I'm able to run my rust test program (using regex) using both rust 1.27 and rust nightly in debug and release without getting a segfault. You may need to run |
Tagging as P-high but @kennytm seems to have this in hand 🎉 |
If this is a linker bug, using a different linker naively seems like it could be a solution. Shipping lld with rustc and having at least an easy opt-in for it, if not enabling it by default, could be another way forward: #39915. |
@SimonSapin It is a dynamic linker bug (the linker that runs when the program starts). Switching to LLD won't fix it. |
When building a program on 10.10.5 / XCode 7.2.1 and running it on a machine with a more recent OS (and presumably a more recent dynamic linker?) I still reproduce the issue. |
…xcrichton Do not allow LLVM to increase a TLS's alignment on macOS. This addresses the various TLS segfault on macOS 10.10. Fix rust-lang#51794. Fix rust-lang#51758. Fix rust-lang#50867. Fix rust-lang#48866. Fix rust-lang#46355. Fix rust-lang#44056.
Update: this is due to LLVM assuming 16-byte alignment for a
#[thread_local]
static that is in fact 8-bytes aligned. Bisected PR might not be directly related, and might only have moved the static from a location that happened to be 16-bytes aligned by chance?Reproduced on three CI builders with macOS 10.10.5, but not on two with 10.11.6.
Not reproduced with the previous Nightly, nightly-2018-06-23. Commit range: cbc4c83...60efbde. Of the PRs merged in this range, eliminating those I’m fairly certain are unrelated leaves #51696 and #51723 which I think are unrelated but am less confident about, and #51580 which touched 69 files in 19 commits.
(Found while upgrading Servo to today’s Nightly: servo/servo#21089 (comment).)
The text was updated successfully, but these errors were encountered: