Skip to content

SIGSEGV in the compiler #82065

Closed
Closed
@pitust

Description

@pitust

Code

#![feature(llvm_asm)]
fn main() {
    unsafe { llvm_asm!("mov $0, %rax" :: "i"(main)); }
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (f74583445 2020-12-18)
binary: rustc
commit-hash: f74583445702e2e27ec4415376f2c540a83d7ded
commit-date: 2020-12-18
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

rustc +stable --version --verbose:

rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-unknown-linux-gnu
release: 1.50.0

Note that on stable RUSTC_BOOTSTRAP=1 is needed to trigger the bug

Error output

Hmm. What should go here?

Segmentation fault (core dumped)
GDB Backtrace

0x00007ffff29005a9 in llvm::X86TargetLowering::LowerAsmOperandForConstraint(llvm::SDValue, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::vector<llvm::SDValue, std::allocator<llvm::SDValue> >&, llvm::SelectionDAG&) const () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
(gdb) bt
#0  0x00007ffff29005a9 in llvm::X86TargetLowering::LowerAsmOperandForConstraint(llvm::SDValue, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::vector<llvm::SDValue, std::allocator<llvm::SDValue> >&, llvm::SelectionDAG&) const () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#1  0x00007ffff0a2241a in llvm::SelectionDAGBuilder::visitInlineAsm(llvm::CallBase const&) ()
   from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#2  0x00007ffff09ff867 in llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#3  0x00007ffff0abf4fe 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 /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#4  0x00007ffff0abe793 in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) ()
   from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#5  0x00007ffff0abb926 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
   from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#6  0x00007ffff27dacd7 in (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
--Type <RET> for more, q to quit, c to continue without paging--
   from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#7  0x00007ffff062478e in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#8  0x00007ffff03fefd2 in llvm::FPPassManager::runOnFunction(llvm::Function&) () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#9  0x00007ffff04059e3 in llvm::FPPassManager::runOnModule(llvm::Module&) () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#10 0x00007ffff03ffa2a in llvm::legacy::PassManagerImpl::run(llvm::Module&) () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-11-rust-1.50.0-nightly.so
#11 0x00007ffff40240ab in LLVMRustWriteOutputFile () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
#12 0x00007ffff3f2656a in rustc_codegen_llvm::back::write::write_output_file () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
#13 0x00007ffff3f2b604 in rustc_codegen_llvm::back::write::codegen () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
#14 0x00007ffff3f4997b in rustc_codegen_ssa::back::write::finish_intra_module_work () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
#15 0x00007ffff3f43cd7 in rustc_codegen_ssa::back::write::execute_work_item () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
#16 0x00007ffff3e64d3a in std::sys_common::backtrace::__rust_begin_short_backtrace () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
#17 0x00007ffff3e6ac6d in core::ops::function::FnOnce::call_once{{vtable-shim}} () from /home/pitust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-54c3daf069bcd3f6.so
--Type <RET> for more, q to quit, c to continue without paging--
#18 0x00007ffff32717ba in alloc::boxed::{{impl}}::call_once<(),FnOnce<()>,alloc::alloc::Global> () at /rustc/f74583445702e2e27ec4415376f2c540a83d7ded/library/alloc/src/boxed.rs:1328
#19 alloc::boxed::{{impl}}::call_once<(),alloc::boxed::Box<FnOnce<()>, alloc::alloc::Global>,alloc::alloc::Global> () at /rustc/f74583445702e2e27ec4415376f2c540a83d7ded/library/alloc/src/boxed.rs:1328
#20 std::sys::unix::thread::{{impl}}::new::thread_start () at /rustc/f74583445702e2e27ec4415376f2c540a83d7ded//library/std/src/sys/unix/thread.rs:71
#21 0x00007ffff317a299 in start_thread () from /usr/lib/libpthread.so.0
#22 0x00007ffff3091153 in clone () from /usr/lib/libc.so.6

I have no clue why this happens, but i guess writing a JIT in rust like this wasn't the smartest idea...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions