Rust: [1.30 beta] Compiler hangs when compiling primal crate for armv7-apple-ios

Created on 28 Sep 2018  路  17Comments  路  Source: rust-lang/rust

See https://github.com/huonw/primal/issues/19


I narrowed the issue down to here: https://github.com/huonw/primal/blob/master/primal-sieve/src/wheel/wheel30.rs#L196-L928 (removing that chunk makes it compile)

A-LLVM C-bug O-ARM P-medium T-compiler regression-from-stable-to-stable

Most helpful comment

This issue has been fixed upstream, so this is just waiting for an LLVM update / cherry-pick now. Relevant commit is https://github.com/llvm-mirror/llvm/commit/0487bd8f42c8b38166ff825d56014d0ff49db604.

All 17 comments

Since this code is fine on other targets, both 32 and 64-bit, I would suspect the fault lies in LLVM codegen. Note that Rust 1.29 has LLVM 7, whereas Rust 1.30 beta has a snapshot from trunk, early LLVM 8. Can you attach a debugger after it's hung and get backtraces for all threads?

Generated using (from within primal):

$ pwd
/Users/mehcode/Workspace/github.com/huonw/primal

$ lldb ~/.cargo/bin/cargo
(lldb) process launch -- +beta build --target armv7-apple-ios
Compiling primal-sieve v0.2.9 [...]
[... waited about 10 minutes ...]
[ hit ctrl-c ]

(lldb) bt all
* thread #2, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff6dd86a16 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6df4f589 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x000000010074a922 cargo`std::thread::park::hcf011ba4ca76f30e + 258
    frame #3: 0x0000000100738f41 cargo`std::sync::mpsc::blocking::WaitToken::wait::hd9230f94c5255b6a + 49
    frame #4: 0x000000010016c201 cargo`_$LT$std..sync..mpsc..shared..Packet$LT$T$GT$$GT$::recv::h5f4c19e5378c2a13 + 721
    frame #5: 0x00000001000d8a59 cargo`_$LT$std..sync..mpsc..Receiver$LT$T$GT$$GT$::recv::hf216cfb8020f004f + 345
    frame #6: 0x00000001001a6092 cargo`cargo::core::compiler::job_queue::JobQueue::drain_the_queue::h3764126a2525930a + 6194
    frame #7: 0x000000010016bac3 cargo`crossbeam_utils::thread::scope::h9914efee12971b2d + 51
    frame #8: 0x000000010019f548 cargo`cargo::core::compiler::context::Context::compile::h0de288078e42e75f + 4680
    frame #9: 0x00000001001301c7 cargo`cargo::ops::cargo_compile::compile_ws::hf4ef6ca68174806f + 13351
    frame #10: 0x000000010012cd5a cargo`cargo::ops::cargo_compile::compile::hbce24daf0756c4b8 + 122
    frame #11: 0x000000010004802b cargo`cargo::commands::build::exec::h46dd9e3b7f9435f8 + 555
    frame #12: 0x000000010000d20f cargo`cargo::cli::main::h08f3a31a714d2f3b + 5759
    frame #13: 0x00000001000207db cargo`cargo::main::h325898d3a6f782ed + 235
    frame #14: 0x0000000100033086 cargo`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h2d4a2fdaa5a923c6 + 6
    frame #15: 0x00000001007501a8 cargo`std::panicking::try::do_call::h32a103bebbb9cfdd (.llvm.3970480468671491771) + 24
    frame #16: 0x000000010075f49f cargo`__rust_maybe_catch_panic + 31
    frame #17: 0x0000000100745d9d cargo`std::rt::lang_start_internal::hb521492a178b86d1 + 237
    frame #18: 0x0000000100022abc cargo`main + 44
    frame #19: 0x0000000100001234 cargo`start + 52
  thread #3
    frame #0: 0x00007fff6dd8728a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff6df4e009 libsystem_pthread.dylib`_pthread_wqthread + 1035
    frame #2: 0x00007fff6df4dbe9 libsystem_pthread.dylib`start_wqthread + 13
  thread #4
    frame #0: 0x00007fff6dd86a16 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6df4f589 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x000000010074a922 cargo`std::thread::park::hcf011ba4ca76f30e + 258
    frame #3: 0x0000000100738f41 cargo`std::sync::mpsc::blocking::WaitToken::wait::hd9230f94c5255b6a + 49
    frame #4: 0x0000000100415940 cargo`_$LT$std..sync..mpsc..stream..Packet$LT$T$GT$$GT$::recv::h877c907696a78808 + 528
    frame #5: 0x000000010041c221 cargo`_$LT$std..sync..mpsc..IntoIter$LT$T$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$::next::h10fa7f5bebcb5368 + 161
    frame #6: 0x000000010041743c cargo`std::sys_common::backtrace::__rust_begin_short_backtrace::h7e24be038b1900f2 + 140
    frame #7: 0x00000001004178a0 cargo`std::panicking::try::do_call::hf4e37f0cd706ffbf (.llvm.1982629740510497656) + 80
    frame #8: 0x000000010075f49f cargo`__rust_maybe_catch_panic + 31
    frame #9: 0x00000001004193d6 cargo`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h4086c5dfcb09db75 + 230
    frame #10: 0x000000010074f768 cargo`std::sys_common::thread::start_thread::ha87665a1386dceb1 + 136
    frame #11: 0x0000000100732c69 cargo`std::sys::unix::thread::Thread::new::thread_start::h23d0c1bead21a1d2 + 9
    frame #12: 0x00007fff6df4e661 libsystem_pthread.dylib`_pthread_body + 340
    frame #13: 0x00007fff6df4e50d libsystem_pthread.dylib`_pthread_start + 377
    frame #14: 0x00007fff6df4dbf9 libsystem_pthread.dylib`thread_start + 13
  thread #5
    frame #0: 0x00007fff6dd8809a libsystem_kernel.dylib`poll + 10
    frame #1: 0x00000001003d3f26 cargo`cargo::util::read2::imp::read2::ha8b8244bf595cdce + 326
    frame #2: 0x00000001001eff79 cargo`cargo::util::process_builder::ProcessBuilder::exec_with_streaming::h7deb28d3de80b685 + 585
    frame #3: 0x000000010033acfc cargo`_$LT$cargo..core..compiler..DefaultExecutor$u20$as$u20$cargo..core..compiler..Executor$GT$::exec_and_capture_output::he8f0e4879b39b8cc + 76
    frame #4: 0x000000010033824e cargo`_$LT$F$u20$as$u20$cargo..core..compiler..job..FnBox$LT$A$C$$u20$R$GT$$GT$::call_box::h734d6a29434fb575 + 2350
    frame #5: 0x00000001001a3eaa cargo`_$LT$F$u20$as$u20$cargo..core..compiler..job..FnBox$LT$A$C$$u20$R$GT$$GT$::call_box::h469ee540027384d0 + 58
    frame #6: 0x00000001001a3eaa cargo`_$LT$F$u20$as$u20$cargo..core..compiler..job..FnBox$LT$A$C$$u20$R$GT$$GT$::call_box::h469ee540027384d0 + 58
    frame #7: 0x00000001001a3f7f cargo`cargo::core::compiler::job::Job::run::h6e94002433c2c06c + 31
    frame #8: 0x00000001001749b2 cargo`_$LT$F$u20$as$u20$crossbeam_utils..thread..FnBox$LT$T$GT$$GT$::call_box::hb008eea6471bc5c6 + 178
    frame #9: 0x000000010075f49f cargo`__rust_maybe_catch_panic + 31
    frame #10: 0x0000000100093f4a cargo`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hfb41ae0dcf629060 + 154
    frame #11: 0x000000010074f768 cargo`std::sys_common::thread::start_thread::ha87665a1386dceb1 + 136
    frame #12: 0x0000000100732c69 cargo`std::sys::unix::thread::Thread::new::thread_start::h23d0c1bead21a1d2 + 9
    frame #13: 0x00007fff6df4e661 libsystem_pthread.dylib`_pthread_body + 340
    frame #14: 0x00007fff6df4e50d libsystem_pthread.dylib`_pthread_start + 377
    frame #15: 0x00007fff6df4dbf9 libsystem_pthread.dylib`thread_start + 13


Not sure I did that right as I haven't played with a debugger much.

That's a good backtrace, but not the interesting process. Cargo is just waiting for for rustc to finish, seen in thread 5 under exec_and_capture_output. I'm looking for what rustc is doing.

I suggest starting the cargo build independently, then (lldb) process attach --name rustc. I think that only works if there's just one rustc running, otherwise you can process attach --pid 123 for a specific one.

Ah. Makes sense. Meant to leave this one running for same amount of time but got distracted. It ran for about 25 minutes.

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff6dd86a16 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6df4f589 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x00000001055c1812 libstd-d913a14a4b766c72.dylib`std::thread::park::hcf011ba4ca76f30e + 258
    frame #3: 0x00000001055a5281 libstd-d913a14a4b766c72.dylib`std::sync::mpsc::blocking::WaitToken::wait::hd9230f94c5255b6a + 49
    frame #4: 0x00000001088b49e8 librustc_codegen_llvm-llvm.dylib`_$LT$std..sync..mpsc..shared..Packet$LT$T$GT$$GT$::recv::h283e3e15f08a3cef + 696
    frame #5: 0x0000000108997975 librustc_codegen_llvm-llvm.dylib`_$LT$std..sync..mpsc..Receiver$LT$T$GT$$GT$::recv::h4dd9e0364b3dd5e7 + 421
    frame #6: 0x00000001088d8c55 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::SharedEmitterMain::check::h54904d87a53fe4c4 (.llvm.15361068577713408237) + 133
    frame #7: 0x00000001088d90ff librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::OngoingCodegen::join::h309f3893243fe16d + 79
    frame #8: 0x0000000108992dd8 librustc_codegen_llvm-llvm.dylib`_$LT$rustc_codegen_llvm..LlvmCodegenBackend$u20$as$u20$rustc_codegen_utils..codegen_backend..CodegenBackend$GT$::join_codegen_and_link::h4cd23f97545295e4 + 120
    frame #9: 0x0000000101f4ef78 librustc_driver-0d3b4d9a9612e751.dylib`rustc_driver::driver::compile_input::h31b03e47e946fdc9 + 9784
    frame #10: 0x0000000101fd86ff librustc_driver-0d3b4d9a9612e751.dylib`rustc_driver::run_compiler_with_pool::he921be7da2482371 + 4191
    frame #11: 0x0000000101f4c8dc librustc_driver-0d3b4d9a9612e751.dylib`rustc_driver::driver::spawn_thread_pool::h5e1b71cbb1fbfc82 + 396
    frame #12: 0x0000000101fd7592 librustc_driver-0d3b4d9a9612e751.dylib`rustc_driver::run_compiler::he50aeac7b58575a1 + 338
    frame #13: 0x0000000101f3baa6 librustc_driver-0d3b4d9a9612e751.dylib`_$LT$scoped_tls..ScopedKey$LT$T$GT$$GT$::set::h4a4b94afd31a07ef + 342
    frame #14: 0x0000000101f70e5e librustc_driver-0d3b4d9a9612e751.dylib`syntax::with_globals::h1e435231748ee4ed + 46
    frame #15: 0x00000001055da62f libstd-d913a14a4b766c72.dylib`__rust_maybe_catch_panic + 31
    frame #16: 0x0000000101fd58da librustc_driver-0d3b4d9a9612e751.dylib`rustc_driver::run::h580060b09b17efd1 + 2698
    frame #17: 0x0000000101fe3b3e librustc_driver-0d3b4d9a9612e751.dylib`rustc_driver::main::ha94c4dc722795849 + 14
    frame #18: 0x0000000101ecbdf6 rustc`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h0ef2149b533e1701 + 6
    frame #19: 0x00000001055c9808 libstd-d913a14a4b766c72.dylib`std::panicking::try::do_call::h32a103bebbb9cfdd (.llvm.3970480468671491771) + 24
    frame #20: 0x00000001055da62f libstd-d913a14a4b766c72.dylib`__rust_maybe_catch_panic + 31
    frame #21: 0x00000001055b658d libstd-d913a14a4b766c72.dylib`std::rt::lang_start_internal::hb521492a178b86d1 + 237
    frame #22: 0x0000000101ecbe5c rustc`main + 44
    frame #23: 0x0000000101ecbde4 rustc`start + 52
  thread #2
    frame #0: 0x00007fff6dd86a16 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6df4f589 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x00000001055c1812 libstd-d913a14a4b766c72.dylib`std::thread::park::hcf011ba4ca76f30e + 258
    frame #3: 0x00000001055a5281 libstd-d913a14a4b766c72.dylib`std::sync::mpsc::blocking::WaitToken::wait::hd9230f94c5255b6a + 49
    frame #4: 0x0000000103f00950 librustc-0d27f23848274e05.dylib`_$LT$std..sync..mpsc..stream..Packet$LT$T$GT$$GT$::recv::h201dca87373605ec + 528
    frame #5: 0x0000000103f07831 librustc-0d27f23848274e05.dylib`_$LT$std..sync..mpsc..IntoIter$LT$T$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$::next::hee0f59966d104b6f + 161
    frame #6: 0x0000000103f0275c librustc-0d27f23848274e05.dylib`std::sys_common::backtrace::__rust_begin_short_backtrace::h4f0dc585bd4fead9 + 140
    frame #7: 0x0000000103f02bc0 librustc-0d27f23848274e05.dylib`std::panicking::try::do_call::h74f170cd9fa5f506 (.llvm.8886808114753586241) + 80
    frame #8: 0x00000001055da62f libstd-d913a14a4b766c72.dylib`__rust_maybe_catch_panic + 31
    frame #9: 0x0000000103f046f6 librustc-0d27f23848274e05.dylib`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hee0f7e7a3aae8011 + 230
    frame #10: 0x00000001055c8a48 libstd-d913a14a4b766c72.dylib`std::sys_common::thread::start_thread::ha87665a1386dceb1 + 136
    frame #11: 0x000000010559e0a9 libstd-d913a14a4b766c72.dylib`std::sys::unix::thread::Thread::new::thread_start::h23d0c1bead21a1d2 + 9
    frame #12: 0x00007fff6df4e661 libsystem_pthread.dylib`_pthread_body + 340
    frame #13: 0x00007fff6df4e50d libsystem_pthread.dylib`_pthread_start + 377
    frame #14: 0x00007fff6df4dbf9 libsystem_pthread.dylib`thread_start + 13
  thread #3
    frame #0: 0x00007fff6dd86a16 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6df4f589 libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x00000001055c1812 libstd-d913a14a4b766c72.dylib`std::thread::park::hcf011ba4ca76f30e + 258
    frame #3: 0x00000001055a5281 libstd-d913a14a4b766c72.dylib`std::sync::mpsc::blocking::WaitToken::wait::hd9230f94c5255b6a + 49
    frame #4: 0x00000001088b4e3d librustc_codegen_llvm-llvm.dylib`_$LT$std..sync..mpsc..shared..Packet$LT$T$GT$$GT$::recv::h96cd84ca2d712ca0 + 701
    frame #5: 0x00000001089972e7 librustc_codegen_llvm-llvm.dylib`_$LT$std..sync..mpsc..Receiver$LT$T$GT$$GT$::recv::h26367cdc3ee01033 + 407
    frame #6: 0x00000001088b0d35 librustc_codegen_llvm-llvm.dylib`std::sys_common::backtrace::__rust_begin_short_backtrace::he5435356e0826bb5 + 4053
    frame #7: 0x00000001088c6d0c librustc_codegen_llvm-llvm.dylib`std::panicking::try::do_call::ha982ac7fd18c4a8f (.llvm.15361068577713408237) + 60
    frame #8: 0x00000001055da62f libstd-d913a14a4b766c72.dylib`__rust_maybe_catch_panic + 31
    frame #9: 0x00000001088ba957 librustc_codegen_llvm-llvm.dylib`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hf0d7cba651529e61 + 167
    frame #10: 0x00000001055c8a48 libstd-d913a14a4b766c72.dylib`std::sys_common::thread::start_thread::ha87665a1386dceb1 + 136
    frame #11: 0x000000010559e0a9 libstd-d913a14a4b766c72.dylib`std::sys::unix::thread::Thread::new::thread_start::h23d0c1bead21a1d2 + 9
    frame #12: 0x00007fff6df4e661 libsystem_pthread.dylib`_pthread_body + 340
    frame #13: 0x00007fff6df4e50d libsystem_pthread.dylib`_pthread_start + 377
    frame #14: 0x00007fff6df4dbf9 libsystem_pthread.dylib`thread_start + 13
  thread #4
    frame #0: 0x00000001098d70e8 librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) + 8
    frame #1: 0x000000010956c567 librustc_codegen_llvm-llvm.dylib`llvm::ARMTargetLowering::PerformCMOVCombine(llvm::SDNode*, llvm::SelectionDAG&) const + 4023
    frame #2: 0x000000010956dbd0 librustc_codegen_llvm-llvm.dylib`llvm::ARMTargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const + 4224
    frame #3: 0x000000010975cee7 librustc_codegen_llvm-llvm.dylib`(anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) + 151
    frame #4: 0x000000010975c3e4 librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) + 1764
    frame #5: 0x0000000109915898 librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1544
    frame #6: 0x00000001099140c2 librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 8370
    frame #7: 0x000000010991158e librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1822
    frame #8: 0x000000010951c214 librustc_codegen_llvm-llvm.dylib`(anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20
    frame #9: 0x0000000109ad3e2a librustc_codegen_llvm-llvm.dylib`llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 138
    frame #10: 0x000000010a3961ee librustc_codegen_llvm-llvm.dylib`llvm::FPPassManager::runOnFunction(llvm::Function&) + 974
    frame #11: 0x000000010a396453 librustc_codegen_llvm-llvm.dylib`llvm::FPPassManager::runOnModule(llvm::Module&) + 67
    frame #12: 0x000000010a3967d7 librustc_codegen_llvm-llvm.dylib`llvm::legacy::PassManagerImpl::run(llvm::Module&) + 695
    frame #13: 0x00000001089eeab6 librustc_codegen_llvm-llvm.dylib`LLVMRustWriteOutputFile + 550
    frame #14: 0x00000001088cce56 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::write_output_file::h51aa72d49c2e043b (.llvm.15361068577713408237) + 86
    frame #15: 0x00000001088a7339 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::codegen::_$u7b$$u7b$closure$u7d$$u7d$::h41cb86b680518476 (.llvm.13810846407243116275) + 761
    frame #16: 0x00000001088a0970 librustc_codegen_llvm-llvm.dylib`rustc::util::common::time_ext::hcd8123cb24f97d34 + 80
    frame #17: 0x00000001088cf3f8 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::codegen::hf98753a3e7904c2f + 2376
    frame #18: 0x00000001088d6ab4 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::execute_work_item::h30fc8218f4df7441 + 6228
    frame #19: 0x00000001088afb6d librustc_codegen_llvm-llvm.dylib`std::sys_common::backtrace::__rust_begin_short_backtrace::h2cbf516cbc3e6fc0 + 541
    frame #20: 0x00000001088c6d5e librustc_codegen_llvm-llvm.dylib`std::panicking::try::do_call::hdccc49ad90c109bf (.llvm.15361068577713408237) + 46
    frame #21: 0x00000001055da62f libstd-d913a14a4b766c72.dylib`__rust_maybe_catch_panic + 31
    frame #22: 0x00000001088ba7a7 librustc_codegen_llvm-llvm.dylib`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::haa21b6c030791e16 + 167
    frame #23: 0x00000001055c8a48 libstd-d913a14a4b766c72.dylib`std::sys_common::thread::start_thread::ha87665a1386dceb1 + 136
    frame #24: 0x000000010559e0a9 libstd-d913a14a4b766c72.dylib`std::sys::unix::thread::Thread::new::thread_start::h23d0c1bead21a1d2 + 9
    frame #25: 0x00007fff6df4e661 libsystem_pthread.dylib`_pthread_body + 340
    frame #26: 0x00007fff6df4e50d libsystem_pthread.dylib`_pthread_start + 377
    frame #27: 0x00007fff6df4dbf9 libsystem_pthread.dylib`thread_start + 13
  thread #5
    frame #0: 0x000000010975b93d librustc_codegen_llvm-llvm.dylib`(anonymous namespace)::DAGCombiner::AddToWorklist(llvm::SDNode*) + 125
    frame #1: 0x000000010975c4bc librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) + 1980
    frame #2: 0x0000000109915898 librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1544
    frame #3: 0x00000001099140c2 librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 8370
    frame #4: 0x000000010991158e librustc_codegen_llvm-llvm.dylib`llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1822
    frame #5: 0x000000010951c214 librustc_codegen_llvm-llvm.dylib`(anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20
    frame #6: 0x0000000109ad3e2a librustc_codegen_llvm-llvm.dylib`llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 138
    frame #7: 0x000000010a3961ee librustc_codegen_llvm-llvm.dylib`llvm::FPPassManager::runOnFunction(llvm::Function&) + 974
    frame #8: 0x000000010a396453 librustc_codegen_llvm-llvm.dylib`llvm::FPPassManager::runOnModule(llvm::Module&) + 67
    frame #9: 0x000000010a3967d7 librustc_codegen_llvm-llvm.dylib`llvm::legacy::PassManagerImpl::run(llvm::Module&) + 695
    frame #10: 0x00000001089eeab6 librustc_codegen_llvm-llvm.dylib`LLVMRustWriteOutputFile + 550
    frame #11: 0x00000001088cce56 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::write_output_file::h51aa72d49c2e043b (.llvm.15361068577713408237) + 86
    frame #12: 0x00000001088a7339 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::codegen::_$u7b$$u7b$closure$u7d$$u7d$::h41cb86b680518476 (.llvm.13810846407243116275) + 761
    frame #13: 0x00000001088a0970 librustc_codegen_llvm-llvm.dylib`rustc::util::common::time_ext::hcd8123cb24f97d34 + 80
    frame #14: 0x00000001088cf3f8 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::codegen::hf98753a3e7904c2f + 2376
    frame #15: 0x00000001088d6ab4 librustc_codegen_llvm-llvm.dylib`rustc_codegen_llvm::back::write::execute_work_item::h30fc8218f4df7441 + 6228
    frame #16: 0x00000001088afb6d librustc_codegen_llvm-llvm.dylib`std::sys_common::backtrace::__rust_begin_short_backtrace::h2cbf516cbc3e6fc0 + 541
    frame #17: 0x00000001088c6d5e librustc_codegen_llvm-llvm.dylib`std::panicking::try::do_call::hdccc49ad90c109bf (.llvm.15361068577713408237) + 46
    frame #18: 0x00000001055da62f libstd-d913a14a4b766c72.dylib`__rust_maybe_catch_panic + 31
    frame #19: 0x00000001088ba7a7 librustc_codegen_llvm-llvm.dylib`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::haa21b6c030791e16 + 167
    frame #20: 0x00000001055c8a48 libstd-d913a14a4b766c72.dylib`std::sys_common::thread::start_thread::ha87665a1386dceb1 + 136
    frame #21: 0x000000010559e0a9 libstd-d913a14a4b766c72.dylib`std::sys::unix::thread::Thread::new::thread_start::h23d0c1bead21a1d2 + 9
    frame #22: 0x00007fff6df4e661 libsystem_pthread.dylib`_pthread_body + 340
    frame #23: 0x00007fff6df4e50d libsystem_pthread.dylib`_pthread_start + 377
    frame #24: 0x00007fff6df4dbf9 libsystem_pthread.dylib`thread_start + 13

OK, so threads 4 and 5 are both deep in LLVM. It will take more digging to figure out why they're stuck, but I feel more comfortable blaming the LLVM upgrade for this now.

discussed at T-compiler meeting .assigning to @nagisa for initial investigation.

I promised to try and minimise it down to something that can be reported to LLVM.

Note before the T-compiler meeting commences: I did not get an opportunity to take a look at any of the issues assigned to me, including this one. Life called.

EDIT: still intending to try and dedicate some time for it this weekend.

Building with optimisations or simply -Cdebug-assertions=off is a good work-around for this problem.

This is what I鈥檝e minimised to (no_core), however while the snippet below does hang rustc鈥檚 LLVM, the regular llc does not hang, which suggests a potential configuration difference that I need to now uncover.


Minimal no_core reproducer

#![feature(no_core, lang_items, intrinsics)]
#![no_core]

#[lang="sized"]
pub trait Sized {}

#[lang="freeze"]
pub trait Freeze {}

#[lang="copy"]
pub trait Copy {}

impl Copy for usize {}
impl Copy for isize {}
impl Copy for *mut u8 {}
impl Copy for *const u8 {}

#[lang = "partial_ord"]
pub trait PartialOrd<Rhs: ?Sized = Self> {
    fn ge(&self, other: &Rhs) -> bool;
}

#[lang = "mul"]
pub trait Mul<RHS=Self> {
    type Output;
    fn mul(self, rhs: RHS) -> Self::Output;
}

#[lang = "panic"]
pub fn panic(elc: &(&'static str, &'static str, u32, u32)) -> ! {
    loop {}
}

impl Mul for isize {
    type Output = isize;
    fn mul(self, other: isize) -> isize { self * other }
}

impl PartialOrd for usize {
    fn ge(&self, other: &usize) -> bool { *self >= *other }
}

extern "rust-intrinsic" {
    pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
}

pub unsafe fn hardcoded_sieve(start: *mut u8, prime: usize) {
    let loop_end = offset(start, 42);
    let p = offset(start, 0);
    let prime_ = prime as isize;

    loop {
        'label0: loop {
            break 'label0;
        }
        while (loop_end as usize) >= (p as usize) {
            *(offset(p, prime_ * 0) as *mut u8) = 254;
        }
    }
}


To reproduce, feed this code to rustc --target=armv7-unknown-linux-gnueabihf --crate-type=rlib.

(Also reproduces on armv6 targets)

LLVM bug filled.

Is this going to be fixed before 1.30 ships? Beta promotion to stable should happen this weekend/monday.

discussed at compiler team meeting. @nagisa listed workarounds (turning either optimizations or debug-assertions off).

We do not plan to have a fix beyond that in time for the beta promotion to stable.

triage: P-medium, since we believe this to be an LLVM issue, don't plan to address this ourselves in the short term, and have listed our known workarounds above,

(Please let me know if I should open a new issue for this.)

I believe I am also running into the same issue. My project hangs if I build for ARMv7 (armv7-unknown-linux-gnueabihf) in debug mode.

Project link: https://github.com/sunjay/caves

There is a script called build-arm that uses cross to cross-compile the project in a docker VM. You can run it with ./build-arm (you need docker and cross installed, see the script for details).

The reason I believe it's the same issue is because I am able to work around it in the same way described above. If I compile with --release it finishes in about a minute whereas if I compile without that it doesn't appear to ever terminate. I checked and it is getting past codegen to LLVM just as seen above.

I'm posting this here so my repo can be used to check if the bug is totally fixed when LLVM is updated again. :)

Here's a link to the repo exactly as it is today: https://github.com/sunjay/caves/tree/e31ada1f12142d77035073ac4d6813b35055c64d

This issue has been fixed upstream, so this is just waiting for an LLVM update / cherry-pick now. Relevant commit is https://github.com/llvm-mirror/llvm/commit/0487bd8f42c8b38166ff825d56014d0ff49db604.

LLVM update with the fix is in and confirmed in #57347, so I'm closing this one as well.

Was this page helpful?
0 / 5 - 0 ratings