Skip to content

Possible assertion failure in BitcodeReader::findFunctionInStream() #67771

@GJDuck

Description

@GJDuck

The attached test case seems to be able to trigger an assetion failure in BitcodeReader::findFunctionInStream() from here:

Error BitcodeReader::findFunctionInStream(...) {
    ...
    assert(VSTOffset == 0 || !F->hasName());
    ... }

Test case: bug.o.gz

Command:

    $ llvm-lto bug.o

Tested on latest HEAD.

Stack trace:

llvm-lto: ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6522: llvm::Error {anonymous}::BitcodeReader::findFunctionInStream(llvm::Function*, llvm::DenseMapBase<llvm::DenseMap<llvm::Function*, long unsigned int>, llvm::Function*, long unsigned int, llvm::DenseMapInfo<llvm::Function*, void>, llvm::detail::DenseMapPair<llvm::Function*, long unsigned int> >::iterator): Assertion `VSTOffset == 0 || !F->hasName()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: debug/llvm-project/llvm/build/bin/llvm-lto bug.o
 #0 0x0000557b94577f46 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) ./debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
 #1 0x0000557b94578362 PrintStackTraceSignalHandler(void*) ./debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x0000557b9457572f llvm::sys::RunSignalHandlers() ./debug/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x0000557b945777ea SignalHandler(int) ./debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007fd728e3c4b0 (/lib/x86_64-linux-gnu/libc.so.6+0x3c4b0)
 #5 0x00007fd728e90ffb __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007fd728e90ffb __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x00007fd728e90ffb pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x00007fd728e3c406 raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007fd728e2287c abort ./stdlib/abort.c:81:7
#10 0x00007fd728e2279b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007fd728e33b86 (/lib/x86_64-linux-gnu/libc.so.6+0x33b86)
#12 0x0000557b9322db3c (anonymous namespace)::BitcodeReader::findFunctionInStream(llvm::Function*, llvm::DenseMapIterator<llvm::Function*, unsigned long, llvm::DenseMapInfo<llvm::Function*, void>, llvm::detail::DenseMapPair<llvm::Function*, unsigned long>, false>) ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6525:51
#13 0x0000557b9322de14 (anonymous namespace)::BitcodeReader::materialize(llvm::GlobalValue*) ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6554:49
#14 0x0000557b9322e8d4 (anonymous namespace)::BitcodeReader::materializeModule() ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6651:36
#15 0x0000557b93df13bf llvm::Module::materializeAll() ./debug/llvm-project/llvm/lib/IR/Module.cpp:449:1
#16 0x0000557b93236c26 llvm::BitcodeModule::getModuleImpl(llvm::LLVMContext&, bool, bool, bool, llvm::ParserCallbacks) ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:7946:40
#17 0x0000557b932383eb llvm::BitcodeModule::parseModule(llvm::LLVMContext&, llvm::ParserCallbacks) ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:8141:62
#18 0x0000557b93238529 llvm::parseBitcodeFile(llvm::MemoryBufferRef, llvm::LLVMContext&, llvm::ParserCallbacks) ./debug/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:8153:44
#19 0x0000557b940d6bd3 parseBitcodeFileImpl(llvm::MemoryBufferRef, llvm::LLVMContext&, bool) ./debug/llvm-project/llvm/lib/LTO/LTOModule.cpp:185:59
#20 0x0000557b940d6d90 llvm::LTOModule::makeLTOModule(llvm::MemoryBufferRef, llvm::TargetOptions const&, llvm::LLVMContext&, bool) ./debug/llvm-project/llvm/lib/LTO/LTOModule.cpp:198:57
#21 0x0000557b940d64e9 llvm::LTOModule::createFromFile(llvm::LLVMContext&, llvm::StringRef, llvm::TargetOptions const&) ./debug/llvm-project/llvm/lib/LTO/LTOModule.cpp:121:47
#22 0x0000557b90e88a75 main ./debug/llvm-project/llvm/tools/llvm-lto/llvm-lto.cpp:1031:43
#23 0x00007fd728e23a90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#24 0x00007fd728e23b49 call_init ./csu/../csu/libc-start.c:128:20
#25 0x00007fd728e23b49 __libc_start_main ./csu/../csu/libc-start.c:347:5
#26 0x0000557b90e85125 _start (debug/llvm-project/llvm/build/bin/llvm-lto+0x5d6125)
Aborted

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions