-
Notifications
You must be signed in to change notification settings - Fork 506
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
lto = "thin"
causes SIGSEGVs when ran under rustdoc
#911
Comments
Yes it does -- and in response to one of the comments, no, But it crashed within Is this reproducible outside of NixOS? e.g. on something more traditional like Fedora or Ubuntu? |
Well, I reproduced it on Fedora 35, so it's not just a NixOS thing... |
Aha, thank you! I still have no idea how lifetimes work with raw pointers, thus the wild speculations.
Tested single-file reproduced from #911 (comment) on default x86_64 unubtu-21.10 with today's rust nightly. Crashes similarly the same way with |
This looks like a codegen bug -- I get this code for setting 000000000004f9a0 <_ZN3std6thread5local17LocalKey$LT$T$GT$4with17h6114d0cd4be760acE>:
4f9a0: 48 83 ec 18 sub $0x18,%rsp
4f9a4: 48 89 34 24 mov %rsi,(%rsp)
4f9a8: ff 17 call *(%rdi)
4f9aa: 48 89 44 24 08 mov %rax,0x8(%rsp)
4f9af: 48 83 f8 00 cmp $0x0,%rax
4f9b3: 74 2c je 4f9e1 <_ZN3std6thread5local17LocalKey$LT$T$GT$4with17h6114d0cd4be760acE+0x41>
4f9b5: 48 8b 44 24 08 mov 0x8(%rsp),%rax
4f9ba: 48 8b 00 mov (%rax),%rax
4f9bd: 48 83 f8 00 cmp $0x0,%rax
assert!(t.get().is_null());
4f9c1: 74 48 je 4fa0b <_ZN3std6thread5local17LocalKey$LT$T$GT$4with17h6114d0cd4be760acE+0x6b>
4f9c3: 48 8d 3d e6 53 09 00 lea 0x953e6(%rip),%rdi # e4db0 <anon.ac26955e2c89c5d8e44f7f86cf1eaf1c.7.llvm.6007769190384261862>
4f9ca: 48 8d 15 3f f8 0a 00 lea 0xaf83f(%rip),%rdx # ff210 <anon.ac26955e2c89c5d8e44f7f86cf1eaf1c.8.llvm.6007769190384261862>
4f9d1: 48 8d 05 88 c6 fc ff lea -0x33978(%rip),%rax # 1c060 <_ZN4core9panicking5panic17h0ba7146865b2f9d6E>
4f9d8: be 23 00 00 00 mov $0x23,%esi
4f9dd: ff d0 call *%rax
4f9df: 0f 0b ud2
4f9e1: 48 8d 3d a4 52 09 00 lea 0x952a4(%rip),%rdi # e4c8c <anon.ac26955e2c89c5d8e44f7f86cf1eaf1c.0.llvm.6007769190384261862>
4f9e8: 48 8d 0d e9 f7 0a 00 lea 0xaf7e9(%rip),%rcx # ff1d8 <anon.ac26955e2c89c5d8e44f7f86cf1eaf1c.3.llvm.6007769190384261862>
4f9ef: 4c 8d 05 ca f7 0a 00 lea 0xaf7ca(%rip),%r8 # ff1c0 <anon.ac26955e2c89c5d8e44f7f86cf1eaf1c.2.llvm.6007769190384261862>
4f9f6: 48 8d 05 13 ca fc ff lea -0x335ed(%rip),%rax # 1c410 <_ZN4core6result13unwrap_failed17h32ef6b3156e8fc57E>
4f9fd: be 46 00 00 00 mov $0x46,%esi
4fa02: 48 8d 54 24 10 lea 0x10(%rsp),%rdx
4fa07: ff d0 call *%rax
4fa09: 0f 0b ud2
4fa0b: 48 8b 04 24 mov (%rsp),%rax
4fa0f: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi
t.set(thread);
4fa14: 48 8b 30 mov (%rax),%rsi
4fa17: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1)
4fa1e: 00 00
000000000004fa20 <_ZN4core3ptr52drop_in_place$LT$std..thread..local..AccessError$GT$17hac4d05594a295cb7E.llvm.6007769190384261862>:
4fa20: c3 ret
4fa21: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1)
4fa28: 00 00 00
4fa2b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) I stepped through and we do execute the end there around I tried to use |
In case it's of any use here is a smaller reproducer extracted from comment 1, uses "only" # Cargo.toml:
[package]
name = "bug"
version = "0.1.0"
edition = "2018"
[dependencies]
rayon-core = ">= 1.9"
[profile.dev]
debug = true
incremental = true
lto = "thin"
opt-level = 2
debug-assertions = false
overflow-checks = false
codegen-units = 256 // src/lib.rs:
use rayon_core::current_num_threads;
#[inline(never)]
pub fn bridge()
{
let /* triggers bug */ _splits = crate::current_num_threads();
}
/// # Examples
///
/// ```
/// use bug::do_bug;
///
/// # fn main() {
/// bug::do_bug()
/// # }
/// ```
pub fn do_bug() {
bridge();
bridge();
bridge();
bridge();
} Reproducer:
I'll spend some time extracting the reproducer from |
Filed new issue against rust: rust-lang/rust#92869 |
Thanks! Let's close this as a compiler issue, not rayon's fault. :) |
In xiph/rav1e#2851 NixOS found out the crash of
rayon-1.5.1
onrav1e
doctests. Here is extracted reproducer:Reproducer run:
Notes:
Cargo.toml
enabledlto = "thin"; opt-level = 2
but be careful:rustdoc
does not seem to passopt-level =
to test itself, only anlto
part. That makes it a bit hard to reason about optimisation mix.Attempt at fetching backtrace:
Echoing comment xiph/rav1e#2851 (comment) here:
"""
Specifically rayon-core-1.9.1/src/registry.rs:
Does rust guarantee that raw worker_thread will point to fully constructed object? Or could actual initialization move downward a bit?
"""
Thank you!
The text was updated successfully, but these errors were encountered: