Skip to content
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 segfault #70117

Closed
haraldh opened this issue Mar 18, 2020 · 27 comments · Fixed by #86950
Closed

rustc segfault #70117

haraldh opened this issue Mar 18, 2020 · 27 comments · Fixed by #86950
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@haraldh
Copy link
Contributor

haraldh commented Mar 18, 2020

Code

Steps to reproduce are in this comment
and in this comment

Meta

rustc --version --verbose:

rustc 1.42.0 (b8cedc004 2020-03-09)
binary: rustc
commit-hash: b8cedc00407a4c56a3bda1ed605c6fc166655447
commit-date: 2020-03-09
host: x86_64-unknown-linux-gnu
release: 1.42.0
LLVM version: 9.0

and

rustc 1.43.0-nightly (c20d7eecb 2020-03-11)
binary: rustc
commit-hash: c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be
commit-date: 2020-03-11
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Error output

gdb backtrace with 1.42.0

Thread 2 "rustc" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffef7ff700 (LWP 258154)]
0x00007ffff482cf95 in __memmove_sse2_unaligned_erms () from /lib64/libc.so.6
(gdb) 
(gdb) bt
#0  0x00007ffff482cf95 in __memmove_sse2_unaligned_erms () from /lib64/libc.so.6
#1  0x00007ffff1b70226 in llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.42.0-stable.so
#2  0x00007ffff1c4d226 in llvm::Function::addAttributes(unsigned int, llvm::AttrBuilder const&) ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.42.0-stable.so
#3  0x00007ffff53b7dd0 in LLVMRustAddFunctionAttribute ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#4  0x00007ffff53abd2e in rustc_codegen_llvm::declare::declare_raw_fn ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#5  0x00007ffff528b3f2 in <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::misc::MiscMethods>::eh_personality ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#6  0x00007ffff5369714 in rustc_codegen_ssa::mir::codegen_mir ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#7  0x00007ffff5287335 in <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#8  0x00007ffff52509ca in rustc_codegen_llvm::base::compile_codegen_unit::module_codegen ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#9  0x00007ffff52ca460 in rustc::dep_graph::graph::DepGraph::with_task ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#10 0x00007ffff5250624 in rustc_codegen_llvm::base::compile_codegen_unit ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#11 0x00007ffff5321fb6 in rustc_codegen_ssa::base::codegen_crate ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#12 0x00007ffff52b49fe in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#13 0x00007ffff5126d6f in rustc_session::utils::<impl rustc_session::session::Session>::time ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#14 0x00007ffff51c1de8 in rustc_interface::passes::QueryContext::enter ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#15 0x00007ffff5123a91 in rustc_interface::queries::Queries::ongoing_codegen ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#16 0x00007ffff4f62224 in rustc_interface::interface::run_compiler_in_existing_thread_pool ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#17 0x00007ffff4f5137d in scoped_tls::ScopedKey<T>::set ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#18 0x00007ffff4f4e584 in syntax::with_globals ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#19 0x00007ffff4f523b0 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#20 0x00007ffff4a18b97 in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:86
#21 0x00007ffff4f64449 in core::ops::function::FnOnce::call_once{{vtable-shim}} ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f0fe6d0442c8c573.so
#22 0x00007ffff49e7e8f in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once ()
    at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/liballoc/boxed.rs:1015
#23 0x00007ffff4a177b0 in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once ()
    at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/liballoc/boxed.rs:1015
#24 std::sys_common::thread::start_thread () at src/libstd/sys_common/thread.rs:13
#25 std::sys::unix::thread::Thread::new::thread_start () at src/libstd/sys/unix/thread.rs:80
#26 0x00007ffff4968432 in start_thread () from /lib64/libpthread.so.0
#27 0x00007ffff4884833 in clone () from /lib64/libc.so.6

gdb backtrace with 1.43.0-nightly (c20d7ee 2020-03-11)

Thread 2 "rustc" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffef1ff700 (LWP 258633)]
0x00007ffff154a1bd in llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.43.0-nightly.so
(gdb) bt
#0  0x00007ffff154a1bd in llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.43.0-nightly.so
#1  0x00007ffff1627226 in llvm::Function::addAttributes(unsigned int, llvm::AttrBuilder const&) ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.43.0-nightly.so
#2  0x00007ffff4efc5c0 in LLVMRustAddFunctionAttribute ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#3  0x00007ffff4d436c6 in rustc_codegen_llvm::declare::declare_raw_fn ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#4  0x00007ffff4dd4a52 in <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::misc::MiscMethods>::eh_personality ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#5  0x00007ffff4e39944 in rustc_codegen_ssa::mir::codegen_mir ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#6  0x00007ffff4dc1e7c in <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#7  0x00007ffff4d3f71a in rustc_codegen_llvm::base::compile_codegen_unit::module_codegen ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#8  0x00007ffff4e237a1 in rustc::dep_graph::graph::DepGraph::with_task ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#9  0x00007ffff4d3f314 in rustc_codegen_llvm::base::compile_codegen_unit ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#10 0x00007ffff4ea0f5f in rustc_codegen_ssa::base::codegen_crate ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#11 0x00007ffff4e35415 in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#12 0x00007ffff4cbce16 in rustc_interface::passes::start_codegen ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#13 0x00007ffff4cd0923 in rustc::ty::context::tls::enter_global ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#14 0x00007ffff4be4126 in rustc_interface::queries::Queries::ongoing_codegen ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#15 0x00007ffff4a93ff6 in rustc_interface::interface::run_compiler_in_existing_thread_pool ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#16 0x00007ffff4a47bcd in scoped_tls::ScopedKey<T>::set ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#17 0x00007ffff4a44c14 in rustc_ast::attr::with_globals ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#18 0x00007ffff4a49060 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#19 0x00007ffff43fa697 in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:86
#20 0x00007ffff4a96486 in core::ops::function::FnOnce::call_once{{vtable-shim}} ()
   from /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-5bafe156ff266a09.so
#21 0x00007ffff43c563f in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once ()
    at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/liballoc/boxed.rs:1017
#22 0x00007ffff43f8f9d in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once ()
    at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/liballoc/boxed.rs:1017
#23 std::sys_common::thread::start_thread () at src/libstd/sys_common/thread.rs:13
#24 std::sys::unix::thread::Thread::new::thread_start () at src/libstd/sys/unix/thread.rs:80
#25 0x00007ffff4344432 in start_thread () from /lib64/libpthread.so.0
#26 0x00007ffff4260833 in clone () from /lib64/libc.so.6
@haraldh haraldh added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 18, 2020
@haraldh
Copy link
Contributor Author

haraldh commented Mar 18, 2020

 /home/harald/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name kernel --edition=2018 kernel/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C panic=abort --cfg 'feature="default"' -C metadata=daec79c354bbdca0 -C extra-filename=-daec79c354bbdca0 --out-dir /home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps --target x86_64-unknown-linux-musl -L dependency=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps -L dependency=/home/harald/git/enarx_sev_kvm_demo/target/release/deps --extern bitflags=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/libbitflags-95ba804a36fe1702.rmeta --extern crt0stack=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/libcrt0stack-9b55dc1549fd6e63.rmeta --extern lazy_static=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/liblazy_static-110cedc9f47571f2.rmeta --extern linux_errno=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/liblinux_errno-024207093360abfd.rmeta --extern linux_syscall=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/liblinux_syscall-4cbc42edd4142e75.rmeta --extern spin=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/libspin-81aa4f2377e3e1aa.rmeta --extern vmbootspec=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/libvmbootspec-6bbf48e889a633a3.rmeta --extern vmsyscall=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/libvmsyscall-f9481026d9d0a4d6.rmeta --extern x86_64=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/deps/libx86_64-3689e0e08bbda521.rmeta -C linker=./cc -C linker=./cc -L native=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/build/kernel-4ea535f90d18f40e/out -l static=asm -L native=/home/harald/git/enarx_sev_kvm_demo/target/x86_64-unknown-linux-musl/release/build/x86_64-435956abdc21ea2b/out

@Centril Centril added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Mar 18, 2020
@haraldh
Copy link
Contributor Author

haraldh commented Mar 18, 2020

oops, corrected backtrace of nightly.. pasted the stable output again.

@Centril Centril added I-nominated A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Mar 18, 2020
@spastorino
Copy link
Member

@haraldh can you share the code that causes this issue?.

@spastorino
Copy link
Member

triage: we couldn't decide the priority of the issue due to the lack of code. Left nomination so we can check again once we have the code that triggers the issue.

@haraldh
Copy link
Contributor Author

haraldh commented Mar 19, 2020

@haraldh can you share the code that causes this issue?.

@spastorino:

$ sudo apt-get install musl-tools
$ git clone --single-branch -b rust_segfault https://github.com/haraldh/enarx_sev_kvm_demo.git
$ cd enarx_sev_kvm_demo/kernel/
$ while cargo build -vvv --release ; do cargo clean; done; 

@pnkfelix
Copy link
Member

@rustbot ping cleanup-crew

@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2020

Error: This team (cleanup-crew) cannot be pinged via this command;it may need to be added to triagebot.toml on the master branch.

Please let @rust-lang/release know if you're having trouble with this bot.

@pnkfelix
Copy link
Member

@rustbot ping cleanup

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Mar 19, 2020
@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

@nikomatsakis
Copy link
Contributor

@pnkfelix
Copy link
Member

Discussed in T-compiler meeting. Prioritizing as P-high for the initial investigation into what's going on. (It may or may not deserve a higher or lower priority once we figure out where the segfault is coming from...)

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Mar 19, 2020
@haraldh
Copy link
Contributor Author

haraldh commented Mar 19, 2020

$ sudo apt-get install musl-tools

could be replaced with

$ export CC=/usr/bin/clang

@haraldh
Copy link
Contributor Author

haraldh commented Mar 19, 2020

updated the branch again, so the assembler code compiles with more toolchains

@haraldh
Copy link
Contributor Author

haraldh commented Mar 19, 2020

are you guys able to reproduce this, or is this only happening with my kernel+glibc+whatever combination?

@mati865
Copy link
Contributor

mati865 commented Mar 20, 2020

Backtrace:

#0  0x00007ffff7f3dcf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x0000555555f45e0e in jobserver::HelperState::for_each_request ()
#2  0x0000555555f461dc in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#3  0x0000555555f46d38 in core::ops::function::FnOnce::call_once{{vtable-shim}} ()
#4  0x0000555555f5bd8f in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/f509b26a7730d721ef87423a72b3fdf8724b4afa/src/liballoc/boxed.rs:1017
#5  0x0000555555f7e70d in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/f509b26a7730d721ef87423a72b3fdf8724b4afa/src/liballoc/boxed.rs:1017
#6  std::sys_common::thread::start_thread () at src/libstd/sys_common/thread.rs:13
#7  std::sys::unix::thread::Thread::new::thread_start () at src/libstd/sys/unix/thread.rs:80
#8  0x00007ffff7f3746f in start_thread () from /usr/lib/libpthread.so.0
#9  0x00007ffff7e4d3d3 in clone () from /usr/lib/libc.so.6

#68663 looks suspicious and I sort of confirmed it: nightly-2020-01-31 works fine but nightly-2020-02-01 crashes.

cc @alexcrichton

@LeSeulArtichaut
Copy link
Contributor

@rustbot modify labels: +regression-from-stable-to-stable

@rustbot
Copy link
Collaborator

rustbot commented Mar 20, 2020

Error: Label regression-from-stable-to-stable can only be set by Rust team members

Please let @rust-lang/release know if you're having trouble with this bot.

@Mark-Simulacrum Mark-Simulacrum added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Mar 20, 2020
@alexcrichton
Copy link
Member

@mati865 that looks like a blocked thread, not a segfaulting threading. You'll likely want to get the backtrace of all threads if you're seeing a crash, and the ones that aren't blocked in pthreads are likely the ones segfaulting.

Or if it is indeed segfaulting in pthreads, it would be good to confirm that by inspecting the instruction to see what the faulting instruction was, since that could hint to possible data corruption via jobserver stuff, but I'm pretty doubtful that's the cause here given the original backtrace in the OP.

This seems unrelated to jobserver stuff from what I'm reading, so I'm going to unsubscribe myself. Feel free to ping me again if it's more confirmed though that jobserver stuff is at fault.

@haraldh
Copy link
Contributor Author

haraldh commented May 5, 2020

Still an issue.. this time with released "stable"

❯ rustc --version
rustc 1.43.0 (4fb7144ed 2020-04-20)

@haraldh
Copy link
Contributor Author

haraldh commented May 5, 2020

$ sudo apt-get install musl-tools
$ git clone --single-branch -b rust_segfault https://github.com/haraldh/enarx.git
$ cd enarx/enarx-keep-sev-shim
$ while cargo build -vvv --release ; do cargo clean; done;

@haraldh
Copy link
Contributor Author

haraldh commented May 5, 2020

And it's segfaulting way more often, than succeeding.

@haraldh
Copy link
Contributor Author

haraldh commented May 5, 2020

Thread 2 "rustc" received signal SIGBUS, Bus error.
[Switching to Thread 0x7fffef1ff700 (LWP 1351394)]
0x00007ffff15391bd in llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.43.0-stable.so

(gdb) bt
#0  0x00007ffff15391bd in llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.43.0-stable.so
#1  0x00007ffff1616226 in llvm::Function::addAttributes(unsigned int, llvm::AttrBuilder const&) ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-9-rust-1.43.0-stable.so
#2  0x00007ffff4ef2c90 in LLVMRustAddFunctionAttribute ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#3  0x00007ffff4ee1813 in rustc_codegen_llvm::declare::declare_raw_fn ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#4  0x00007ffff4dbfff2 in <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::misc::MiscMethods>::eh_personality ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#5  0x00007ffff4e2ee84 in rustc_codegen_ssa::mir::codegen_mir ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#6  0x00007ffff4df0bac in <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#7  0x00007ffff4d3657a in rustc_codegen_llvm::base::compile_codegen_unit::module_codegen ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#8  0x00007ffff4e1ad81 in rustc::dep_graph::graph::DepGraph::with_task ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#9  0x00007ffff4d36144 in rustc_codegen_llvm::base::compile_codegen_unit ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#10 0x00007ffff4e4fc89 in rustc_codegen_ssa::base::codegen_crate ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#11 0x00007ffff4e02895 in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#12 0x00007ffff4cb3436 in rustc_interface::passes::start_codegen ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#13 0x00007ffff4cc6a93 in rustc::ty::context::tls::enter_global ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#14 0x00007ffff4bd8846 in rustc_interface::queries::Queries::ongoing_codegen ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#15 0x00007ffff4a875e6 in rustc_interface::interface::run_compiler_in_existing_thread_pool ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#16 0x00007ffff4a3aacc in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#17 0x00007ffff43eb627 in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:86
#18 0x00007ffff4a89eb6 in core::ops::function::FnOnce::call_once{{vtable-shim}} ()
   from /home/harald/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-7e244282122ae6e4.so
#19 0x00007ffff43b65bf in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once ()
    at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/liballoc/boxed.rs:1017
#20 0x00007ffff43e9f2d in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once ()
    at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/liballoc/boxed.rs:1017
#21 std::sys_common::thread::start_thread () at src/libstd/sys_common/thread.rs:13
#22 std::sys::unix::thread::Thread::new::thread_start () at src/libstd/sys/unix/thread.rs:80
#23 0x00007ffff4333432 in start_thread () from /lib64/libpthread.so.0
#24 0x00007ffff424f9d3 in clone () from /lib64/libc.so.6
(gdb) 

@haraldh
Copy link
Contributor Author

haraldh commented May 5, 2020

for a successful build I have to do:

while ! cargo build --release ; do :; done; 

@tmiasko
Copy link
Contributor

tmiasko commented May 9, 2020

There is a mismatch between rust_eh_personality declared by rustc (which has i32 return type and variadic arguments) and one from the crate. The issue can be reproduced with code below, but observing it might require enabled LLVM assertions:

#![no_std]

#[no_mangle]
pub extern "C" fn rust_eh_personality() {
}

#[no_mangle]
pub fn zzz(a: Option<usize>) -> usize {
    a.unwrap()
}
rustc: .../llvm-project/llvm/include/llvm/Support/Casting.h:264: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::Function; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::Function*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Using the same type signature seems to work fine, although it requires ZST to workaround requirement for at least one named argument.

@haraldh
Copy link
Contributor Author

haraldh commented May 12, 2020

Oh, you are right.. I can totally remove it and it does not segfault anymore!
Thanks!

@haraldh
Copy link
Contributor Author

haraldh commented May 12, 2020

so, I added #[cfg(debug_assertions)] to rust_eh_personality because it's only needed in the debug profile, and seems to cause the segfault in release.

@camelid camelid added I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 22, 2020
@hussein-aitlahcen
Copy link

Hi folks, I think I encountered the same issue, I've commented here with a similar stacktrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.