-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
segfault on 'index out of bounds' OS X Yosemite #51794
Comments
I cannot reproduce on macOS 10.13.5 (High Sierra). @rust-lang/release if anyone can reproduce and bisect, that would be amazing. cc @rust-lang/compiler -- stable regression |
I bet it is the same cause as #51758 (misaligned TLS). |
Seems likely -- this is in stable, though, so probably not caused by that. Getting confirmation would be good as well. |
The use of --release matches #50586 |
This is the reverse of that PR; this bug seems to only happen without |
This does indeed seem quite bad. |
I cannot reproduce on my laptop, but it is 10.11.6. I'll have to see if I have a machine running 10.10 anywhere. |
@felipenoris Could you load |
Sure. I'll work on that. |
$ lldb segfault
(lldb) target create "segfault"
Current executable set to 'segfault' (x86_64).
(lldb) run
Process 57139 launched: '/Users/felipenoris/Documents/src/learnrust/segfault/target/debug/segfault' (x86_64)
segfault was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 57139 stopped
* thread #1: tid = 0x793cbc, 0x0000000100011abf segfault`std::panicking::rust_panic_with_hook::hc2253a5bcda7eda7 [inlined] core::ptr::swap_nonoverlapping_bytes::h90af7d9428701cbf + 16 at ptr.rs:237, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x0000000100011abf segfault`std::panicking::rust_panic_with_hook::hc2253a5bcda7eda7 [inlined] core::ptr::swap_nonoverlapping_bytes::h90af7d9428701cbf + 16 at ptr.rs:237 [opt] |
does running the |
Thanks @felipenoris! The segfault again happens from BTW could you also try this:
|
|
About the toolchain: $ cargo install rustup-toolchain-install-master
...
$ rustup-toolchain-install-master 77a8ed98fc66821a410b0c4696ba99b07b713467
Segmentation fault: 11 |
@felipenoris Does the prebuilt binary work then? |
@kennytm , with the prebuilt binaries results looks good. It replaces the runtime error with compile-time error.
|
Even if I rewrite the program to get a runtime error, the segfault doesn't happen. fn main() {
let x = [1];
let i = 1;
println!("{}", x[i]);
} $ cargo +77a8ed98fc66821a410b0c4696ba99b07b713467 run
Compiling segfault v0.1.0 (file:///Users/felipenoris/Documents/src/learnrust/segfault)
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Running `target/debug/segfault`
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:4:20
note: Run with `RUST_BACKTRACE=1` for a backtrace. |
Some discussion on IRC here https://botbot.me/mozilla/rustc/2018-06-28/?msg=101569375&page=2 |
…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.
I got another code example that reproduces the segfault. Again, the solution by @kennytm also covers this. fn main() {
let i: u8 = 254;
println!("{}", i+2);
} $ cargo run
Compiling strings v0.1.0 (file:///Users/felipenoris/Documents/src/learnrust/strings)
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Running `target/debug/strings`
Segmentation fault: 11
$ cargo +77a8ed98fc66821a410b0c4696ba99b07b713467 run
Compiling strings v0.1.0 (file:///Users/felipenoris/Documents/src/learnrust/strings)
Finished dev [unoptimized + debuginfo] target(s) in 1.57s
Running `target/debug/strings`
thread 'main' panicked at 'attempt to add with overflow', src/main.rs:5:20
note: Run with `RUST_BACKTRACE=1` for a backtrace. |
I get Segmentation Fault on this code when running the debug binary.
Only happens on OS X Yosemite 10.10.5 .
Meta
rustc 1.27.0 (3eda71b 2018-06-19)
binary: rustc
commit-hash: 3eda71b
commit-date: 2018-06-19
host: x86_64-apple-darwin
release: 1.27.0
LLVM version: 6.0
The text was updated successfully, but these errors were encountered: