Skip to content

rustc segfault during inline asm lowering #50268

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mark-i-m opened this issue Apr 27, 2018 · 4 comments
Closed

rustc segfault during inline asm lowering #50268

mark-i-m opened this issue Apr 27, 2018 · 4 comments
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

Comments

@mark-i-m
Copy link
Member

$ rustc --version
rustc 1.27.0-nightly (ac3c2288f 2018-04-18)

The following code causes rustc to segfault:

#![feature(asm)]

fn main() {
    unsafe {
        asm!{
            "
            jmp $0
            "
             : /* no outputs */
             : "i"(main)
             : "memory"
             : "volatile"
        };
    }
}
$ rustc +nightly test.rs 
Segmentation fault (core dumped)

Backtrace

(gdb) bt
#0  0x00007fffed47cd30 in llvm::X86TargetLowering::LowerAsmOperandForConstraint(llvm::SDValue, std::string&, std::vector<llvm::SDValue, std::allocator<llvm::SDValue> >&, llvm::SelectionDAG&) const ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#1  0x00007fffee06c219 in llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#2  0x00007fffee079a21 in llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#3  0x00007fffee080abc in llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#4  0x00007fffee0b7e34 in llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, bool&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#5  0x00007fffee0c09c6 in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#6  0x00007fffee0c1fd3 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) [clone .part.964] ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#7  0x00007fffed3e9404 in (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#8  0x00007fffee2b9497 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#9  0x00007fffeeaf7eca in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#10 0x00007fffeeaf7f63 in llvm::FPPassManager::runOnModule(llvm::Module&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#11 0x00007fffeeaf88b0 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#12 0x00007fffed32b834 in LLVMRustWriteOutputFile ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#13 0x00007fffed20faaa in rustc_trans::back::write::write_output_file::h0d7fb0b8d06dd68c ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#14 0x00007fffed2fe0f6 in rustc_trans::back::write::codegen::_$u7b$$u7b$closure$u7d$$u7d$::h2ef1b4f87efdccd8 ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#15 0x00007fffed2f9868 in rustc::util::common::time_ext::h12a0d4188ad31d17 ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#16 0x00007fffed211ade in rustc_trans::back::write::codegen::h03ea74510797bb18 ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#17 0x00007fffed21961a in rustc_trans::back::write::execute_work_item::h7f74cc8282ca428e ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#18 0x00007fffed2cb2fa in std::sys_common::backtrace::__rust_begin_short_backtrace::h520ad153f269c32c ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#19 0x00007fffed21e468 in std::panicking::try::do_call::h6244435df3610d7a ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#20 0x00007ffff76779cf in __rust_maybe_catch_panic () at libpanic_unwind/lib.rs:105
#21 0x00007fffed2f5f21 in _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::he38fa61696581e56 ()
   from /nobackup/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-llvm.so
#22 0x00007ffff766bca8 in _$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::h0137220ca4823a86 () at /checkout/src/liballoc/boxed.rs:647
#23 std::sys_common::thread::start_thread::h4a77c2e692e25ce6 () at libstd/sys_common/thread.rs:24
#24 0x00007ffff763a209 in std::sys::unix::thread::Thread::new::thread_start::h5c4ff67e1691aab6 () at libstd/sys/unix/thread.rs:90
#25 0x00007ffff188a6ba in start_thread (arg=0x7fffe5dff700) at pthread_create.c:333
#26 0x00007ffff731941d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
@nagisa nagisa added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-inline-assembly Area: Inline assembly (`asm!(…)`) labels Apr 29, 2018
@mark-i-m
Copy link
Member Author

Confirmed that this is still happening

$ rustc --version
rustc 1.30.0-nightly (33b923fd4 2018-08-18)

@levex
Copy link
Contributor

levex commented Sep 30, 2018

Is this not a duplicate (probably, vice-versa) of #51130? I get the same LLVM assertion failure.

@XAMPPRocky XAMPPRocky added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Oct 2, 2018
@nikic
Copy link
Contributor

nikic commented Nov 3, 2018

Yep, this is a duplicate of #51130.

@mark-i-m
Copy link
Member Author

mark-i-m commented Nov 3, 2018

Yep, I will close it.

@mark-i-m mark-i-m closed this as completed Nov 3, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.
Projects
None yet
Development

No branches or pull requests

5 participants