[llvm] [DWARF] Emit a worst-case prologue_end flag for pathological inputs (PR #107849)

Haojian Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 02:58:03 PST 2024


hokein wrote:

> @hokein would there be any further context than that -- presumably UBSan can produce a stack trace? There are a lot of references to `MachineInstr` here, and not a lot to go on.

Unfortunately, usan-built clang didn't give a stacktrace. I see a normal assertion-enabled clang (built on bf483ddb4206) also crashes, stacktrace:

```
$ ./bin/clang -O2 -g -c /t/t.ii                                                                                                                                                                                                                   <<<
/t/t.ii:1:10: warning: non-void function does not return a value [-Wreturn-type]
    1 | int a() {}
      |          ^
clang: /workspace/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:168: reference llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::MachineBasicBlock, true, false, void, false, void>, false, true>::operator*() const [OptionsT = llvm::ilist_detail::node_options<llvm::MachineBasicBlock, true, false, void, false, void>, IsReverse = false, IsConst = true]: Assertion `!NodePtr->isKnownSentinel()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./bin/clang -O2 -g -c /t/t.ii
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/t/t.ii'.
4.      Running pass 'X86 Assembly Printer' on function '@_Z1av'
 #0 0x000055848fd8e988 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x000055848fd8ca90 llvm::sys::RunSignalHandlers() /workspace/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x000055848fd08326 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /workspace/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #3 0x000055848fd08326 CrashRecoverySignalHandler(int) /workspace/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51
 #4 0x00007f09fac591a0 (/lib/x86_64-linux-gnu/libc.so.6+0x3d1a0)
 #5 0x00007f09faca70ec __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007f09fac59102 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007f09fac424f2 abort ./stdlib/abort.c:81:7
 #8 0x00007f09fac42415 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007f09fac51d32 (/lib/x86_64-linux-gnu/libc.so.6+0x35d32)
#10 0x0000558490a8ec98 findPrologueEndLoc(llvm::MachineFunction const*) /workspace/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:0:32
#11 0x0000558490a8ec98 llvm::DwarfDebug::emitInitialLocDirective(llvm::MachineFunction const&, unsigned int) /workspace/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2279:53
#12 0x0000558490a8f0c2 llvm::DwarfDebug::beginFunctionImpl(llvm::MachineFunction const*) /workspace/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2327:16
#13 0x0000558490a61b0e llvm::AsmPrinter::emitFunctionHeader() /workspace/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1057:37
#14 0x0000558490a645cd llvm::AsmPrinter::emitFunctionBody() /workspace/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1768:3
#15 0x000055848ebddaf1 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) /workspace/llvm-project/llvm/lib/Target/X86/X86AsmPrinter.cpp:91:3
#16 0x000055848f3788f6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /workspace/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:13
#17 0x000055848f817ae6 llvm::FPPassManager::runOnFunction(llvm::Function&) /workspace/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1406:27
#18 0x000055848f81e432 llvm::FPPassManager::runOnModule(llvm::Module&) /workspace/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1452:13
#19 0x000055848f818255 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /workspace/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1521:27
#20 0x000055848f818255 llvm::legacy::PassManagerImpl::run(llvm::Module&) /workspace/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:44
#21 0x000055848ff7ea6e llvm::TimeTraceScope::~TimeTraceScope() /workspace/llvm-project/llvm/include/llvm/Support/TimeProfiler.h:206:9
#22 0x000055848ff7ea6e (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /workspace/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1202:3
#23 0x000055848ff7ea6e (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) /workspace/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1224:3
#24 0x000055848ff7ea6e clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) /workspace/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1387:13
#25 0x00005584904f8c00 std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>::~unique_ptr() /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:397:6
#26 0x00005584904f8c00 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /workspace/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:354:3

```


https://github.com/llvm/llvm-project/pull/107849


More information about the llvm-commits mailing list