Segfault compiling hello world on Linux Mint 19
Howdy! Really happy to see an early version of the compiler out there for us to play with!
I just tried to compile an Erlang hello world and got a segfault. Here's the code:
-module(init).
-export([start/0]).
start() ->
erlang:display(hello_world).
Here's my system info:
OS: Linux Mint 19.3 Cinnamon
Linux kernel: 4.15.0-62-generic
Procesor: Intel Core i7-8550U
And here's my output:
$ /opt/lumen/bin/lumen compile -v ./hello_world.erl
Compiling ./hello_world.erl
[1] 6558 segmentation fault (core dumped) /opt/lumen/bin/lumen compile -v ./hello_world.erl
Any other debug logs or something I can generate to help provide more info?
Use can use lldb to get a backtrace:
lldb /opt/lumen/bin/lumen -- compile -v ./hello_world.erl
run
bt
run will run until you hit the segfault, then bt will show the backtrace at the point where the segfault happens. Post the backtrace.
Well that's a bummer! Seems like its probably an issue with how we packaged the compiler for Linux. If you can capture a backtrace like Luke suggested, that'd be super helpful; otherwise I'll try and repro with Docker when I'm finished up with a few of the other bugs
Here's the backtrace info:
$ lldb /opt/lumen/bin/lumen -- compile -v ./init.erl
(lldb) target create "/opt/lumen/bin/lumen"
Current executable set to '/opt/lumen/bin/lumen' (x86_64).
(lldb) settings set -- target.run-args "compile" "-v" "./init.erl"
(lldb) run
Process 22572 launched: '/opt/lumen/bin/lumen' (x86_64)
Compiling ./init.erl
Process 22572 stopped
* thread #2, name = 'lumen', stop reason = signal SIGSEGV: invalid address (fault address: 0x800000000)
frame #0: 0x00005555575ecfb1 lumen`mlir::LLVM::LLVMStructType::setBody(llvm::ArrayRef<mlir::LLVM::LLVMType>, bool) + 641
lumen`mlir::LLVM::LLVMStructType::setBody:
-> 0x5555575ecfb1 <+641>: movq (%rax), %rax
0x5555575ecfb4 <+644>: testq %rax, %rax
0x5555575ecfb7 <+647>: je 0x5555575ed0e5 ; <+949>
0x5555575ecfbd <+653>: movq 0x10(%rax), %rax
(lldb) bt
* thread #2, name = 'lumen', stop reason = signal SIGSEGV: invalid address (fault address: 0x800000000)
* frame #0: 0x00005555575ecfb1 lumen`mlir::LLVM::LLVMStructType::setBody(llvm::ArrayRef<mlir::LLVM::LLVMType>, bool) + 641
frame #1: 0x00005555575ecad6 lumen`mlir::LLVM::LLVMType::createStructTy(mlir::MLIRContext*, llvm::ArrayRef<mlir::LLVM::LLVMType>, llvm::Optional<llvm::StringRef>, bool) + 342
frame #2: 0x00005555574be02d lumen`lumen::TargetInfo::TargetInfo(llvm::TargetMachine*, mlir::MLIRContext*) + 1421
frame #3: 0x00005555574bafc2 lumen`lumen::eir::ConvertEIRToLLVMPass::runOnOperation() + 402
frame #4: 0x0000555557617b6f lumen`mlir::Pass::run(mlir::Operation*, mlir::AnalysisManager) + 223
frame #5: 0x000055555761bb52 lumen`mlir::PassManager::run(mlir::ModuleOp) + 418
frame #6: 0x0000555557507fb1 lumen`MLIRLowerModule + 17
frame #7: 0x0000555557505a42 lumen`liblumen_mlir::module::Module::lower::h0a4a0c86d67c5594 + 34
frame #8: 0x00005555572ae845 lumen`liblumen_compiler::compiler::queries::get_llvm_dialect_module::hb4864d44652a2989 + 405
frame #9: 0x0000555557228c48 lumen`salsa::runtime::Runtime$LT$DB$GT$::execute_query_implementation::heb303b5bcbb3ee57 + 328
frame #10: 0x0000555557270e8a lumen`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read_upgrade::hfb4e540eca498918 + 2138
frame #11: 0x00005555572767a8 lumen`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read::h3e80036de32232dd + 568
frame #12: 0x0000555557241ad8 lumen`_$LT$salsa..derived..DerivedStorage$LT$DB$C$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$DB$C$Q$GT$$GT$::try_fetch::h666cc05ace5a9b09 + 888
frame #13: 0x00005555572af31b lumen`liblumen_compiler::compiler::queries::get_llvm_module::h6adcc5caeb66357a + 187
frame #14: 0x0000555557227f18 lumen`salsa::runtime::Runtime$LT$DB$GT$::execute_query_implementation::h78e9ee12477fe077 + 328
frame #15: 0x000055555726d84a lumen`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read_upgrade::hbe93ca91c1d23fc4 + 2138
frame #16: 0x0000555557279498 lumen`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read::h7071a15bbcdcce00 + 568
frame #17: 0x00005555572444e8 lumen`_$LT$salsa..derived..DerivedStorage$LT$DB$C$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$DB$C$Q$GT$$GT$::try_fetch::hbd9e367efb7bccc5 + 888
frame #18: 0x00005555572b0012 lumen`liblumen_compiler::compiler::queries::compile::h6200ec8f72be1cdf + 626
frame #19: 0x00005555572288f5 lumen`salsa::runtime::Runtime$LT$DB$GT$::execute_query_implementation::hab518cbba333722b + 325
frame #20: 0x000055555725c90a lumen`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read_upgrade::h3948fe9222884e1d + 2074
frame #21: 0x0000555557278d22 lumen`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read::h6eb9ff24bd6b912d + 562
frame #22: 0x0000555557242555 lumen`_$LT$salsa..derived..DerivedStorage$LT$DB$C$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$DB$C$Q$GT$$GT$::try_fetch::h8e210aec83111ba4 + 805
frame #23: 0x00005555572c455d lumen`_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h22ae25e5b1df644f + 61
frame #24: 0x00005555572bc6d2 lumen`async_task::raw::RawTask$LT$F$C$R$C$S$C$T$GT$::run::h235a15e492cbf498 + 114
frame #25: 0x00005555572a7c9c lumen`std::sys_common::backtrace::__rust_begin_short_backtrace::h7e758b03affaa6fb + 92
frame #26: 0x00005555572beb8e lumen`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h5c51da0d808debbb + 78
frame #27: 0x0000555559a7cc1a lumen`std::sys::unix::thread::Thread::new::thread_start::h8b0ae441dc3343d4 [inlined] _$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::h5b84f52b19042f22 at boxed.rs:1034
frame #28: 0x0000555559a7cc14 lumen`std::sys::unix::thread::Thread::new::thread_start::h8b0ae441dc3343d4 [inlined] _$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::h6e1ef057e35f3144 at boxed.rs:1034
frame #29: 0x0000555559a7cc0b lumen`std::sys::unix::thread::Thread::new::thread_start::h8b0ae441dc3343d4 at thread.rs:87
frame #30: 0x00007ffff77b16db libpthread.so.0`start_thread + 219
frame #31: 0x00007ffff6b9ba3f libc.so.6`__GI___clone at clone.S:95
This looks like the same point as https://github.com/lumen/lumen/issues/574#issuecomment-687341477
Duplicate of #572
Discussed on Dec 9 standup. Assigned to @bitwalker
This should now be resolved using the latest on develop combined with our latest llvm release. See the instructions in the readme for details on setup.
NOTE: Tested using Debian 11