Skip to content

wasm-ld crash related to exceptions and LTO #14776

Closed
@gl84

Description

@gl84

While preparing tests over a custom libpng build I encountered a wasm-ld crash that is triggered through the wasm-ld flags
-mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj:

It seems a recent change creates a crash in wasm-ld (37bf094 works).

@aheejin Do you have an idea?

The stacktrace and invocation is:
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/IR/Instructions.h:2784: llvm::Value *llvm::PHINode::getIncomingValueForBlock(const llvm::BasicBlock *) const: AssertionIdx >= 0 && "Invalid basic block argument!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /emsdk/upstream/bin/wasm-ld -o catch2_test.wasm test/libcatch2_font_library_main.bc /png/wasm_32/install/lib/libpng.bc -L/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj --import-undefined --export-if-defined=png_destroy_read_struct --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024
1 . Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2 . Running pass 'WebAssembly Instruction Selection' on function '@_ZN5Catch5clara8TextFlowlsERNSt3__213basic_ostreamIcNS2_11char_traitsIcEEEERKNS1_6ColumnE'
#0 0x00007f6d79c931a3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x19471a3)
#1 0x00007f6d79c90f4e llvm::sys::RunSignalHandlers() (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x1944f4e)
#2 0x00007f6d79c9366f SignalHandler(int) Signals.cpp:0:0
#3 0x00007f6d7c2d53c0 __restore_rt (/usr/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007f6d7803618b raise (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
#5 0x00007f6d78015859 abort (/usr/lib/x86_64-linux-gnu/libc.so.6+0x25859)
#6 0x00007f6d78015729 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x25729)
#7 0x00007f6d78026f36 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#8 0x00007f6d7a55a788 llvm::SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(llvm::BasicBlock const*) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x220e788)
#9 0x00007f6d7a559d44 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x220dd44)
#10 0x00007f6d7a5f9aa0 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x22adaa0)
#11 0x00007f6d7a5f8f1d llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x22acf1d)
#12 0x00007f6d7a5f5751 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x22a9751)
#13 0x00007f6d7a0ce10d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x1d8210d)
#14 0x00007f6d79e0fcd8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x1ac3cd8)
#15 0x00007f6d79e180b1 llvm::FPPassManager::runOnModule(llvm::Module&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x1acc0b1)
#16 0x00007f6d79e107eb llvm::legacy::PassManagerImpl::run(llvm::Module&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x1ac47eb)
#17 0x00007f6d7b4f50a6 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_deletellvm::lto::NativeObjectStream > (unsigned int)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0
#18 0x00007f6d7b4f4562 llvm::lto::backend(llvm::lto::Config const&, std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_deletellvm::lto::NativeObjectStream > (unsigned int)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x31a8562)
#19 0x00007f6d7b4e8546 llvm::lto::LTO::runRegularLTO(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_deletellvm::lto::NativeObjectStream > (unsigned int)>) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x319c546)
#20 0x00007f6d7b4e7c12 llvm::lto::LTO::run(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_deletellvm::lto::NativeObjectStream > (unsigned int)>, std::function<std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_deletellvm::lto::NativeObjectStream > (unsigned int)> (unsigned int, llvm::StringRef)>) (/emsdk/upstream/bin/../lib/libLLVM-13git.so+0x319bc12)
#21 0x0000000000765496 lld::wasm::BitcodeCompiler::compile() (/emsdk/upstream/bin/wasm-ld+0x765496)
#22 0x0000000000767189 lld::wasm::SymbolTable::addCombinedLTOObject() (/emsdk/upstream/bin/wasm-ld+0x767189)
#23 0x00000000007508ee lld::wasm::(anonymous namespace)::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) Driver.cpp:0:0
#24 0x000000000074b4ba lld::wasm::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) (/emsdk/upstream/bin/wasm-ld+0x74b4ba)
#25 0x00000000003d545e lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) lld.cpp:0:0
#26 0x00000000003d4ff3 main (/emsdk/upstream/bin/wasm-ld+0x3d4ff3)
#27 0x00007f6d780170b3 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#28 0x00000000003d4cda _start (/emsdk/upstream/bin/wasm-ld+0x3d4cda)
Aborted (core dumped)
`

The wasm-ld call that produced the crash
/emsdk/upstream/bin/wasm-ld -o catch2_test.wasm catch2_main.bc /png/wasm_32/install/lib/libpng.bc -L/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj --import-undefined --export-if-defined=png_destroy_read_struct --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024

I'm trying to create a source only repro case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions