bug: crash on mac os with `-g -fdebug-macro` options
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Repro
OS: macOS 15.7.3
```
$ cat main.cpp
int main(){};
$ clang++ --version
Homebrew clang version 22.1.8
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/22.1.8/bin
Configuration file: /opt/homebrew/Cellar/llvm/22.1.8/etc/clang/arm64-apple-darwin24.cfg
$ clang++ -c -g -fdebug-macro main.cpp
Stack dump:
0. Program arguments: clang++ -c -g -fdebug-macro main.cpp
1. parser at end of file
2. Code generation
#0 0x000000011adfc8ec llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x409c8ec)
#1 0x0000000116e8f650 llvm::sys::CleanupOnSignal(unsigned long) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x12f650)
#2 0x000000011add37d4 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x40737d4)
#3 0x000000011add38b0 CrashRecoverySignalHandler(int) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x40738b0)
#4 0x000000019f0a16a4 (/usr/lib/system/libsystem_platform.dylib+0x1804ad6a4)
#5 0x000000011785d188 llvm::AsmPrinter::emitDwarfSymbolReference(llvm::MCSymbol const*, bool) const (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0xafd188)
#6 0x000000011785d188 llvm::AsmPrinter::emitDwarfSymbolReference(llvm::MCSymbol const*, bool) const (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0xafd188)
#7 0x000000011788c820 llvm::DwarfDebug::emitDebugMacinfoImpl(llvm::MCSection*) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0xb2c820)
#8 0x00000001178806f4 llvm::DwarfDebug::endModule() (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0xb206f4)
#9 0x000000011784f570 llvm::AsmPrinter::doFinalization(llvm::Module&) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0xaef570)
#10 0x00000001170540c4 llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x2f40c4)
#11 0x000000011704ad7c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x2ead7c)
#12 0x000000010a214d04 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::__1::unique_ptr>, clang::BackendConsumer*) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x1330d04)
#13 0x000000010a43d358 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x1559358)
#14 0x00000001090c6028 clang::ParseAST(clang::Sema&, bool, bool) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x1e2028)
#15 0x000000010a9cbb20 clang::FrontendAction::Execute() (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x1ae7b20)
#16 0x000000010a969308 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x1a85308)
#17 0x000000010aa04d6c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x1b20d6c)
#18 0x00000001049cd2f0 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/homebrew/Cellar/llvm/22.1.8/bin/clang-22+0x1000052f0)
#19 0x00000001049cb390 ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) (/opt/homebrew/Cellar/llvm/22.1.8/bin/clang-22+0x100003390)
#20 0x00000001049ccbb0 int llvm::function_ref&)>::callback_fn(long, llvm::SmallVectorImpl&) (/opt/homebrew/Cellar/llvm/22.1.8/bin/clang-22+0x100004bb0)
#21 0x000000010a6f0724 void llvm::function_ref::callback_fn>, std::__1::basic_string, std::__1::allocator>*, bool*) const::$_0>(long) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x180c724)
#22 0x0000000116ddeccc llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libLLVM.dylib+0x7eccc)
#23 0x000000010a6f03d0 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__1::basic_string, std::__1::allocator>*, bool*) const (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x180c3d0)
#24 0x000000010a6c00e0 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x17dc0e0)
#25 0x000000010a6d9310 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/homebrew/Cellar/llvm/22.1.8/lib/libclang-cpp.dylib+0x17f5310)
#26 0x00000001049ca3c0 clang_main(int, char**, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/22.1.8/bin/clang-22+0x1000023c0)
#27 0x00000001049d46c4 main (/opt/homebrew/Cellar/llvm/22.1.8/bin/clang-22+0x10000c6c4)
#28 0x000000019ecc6b98
```
Contributor guide
Research direction
Reproduce the crash with the command shown and the minimal main.cpp, then trace the stack from llvm::DwarfDebug::emitDebugMacinfoImpl through llvm::AsmPrinter::emitDwarfSymbolReference and endModule. Done means clang++ completes compilation with -g -fdebug-macro on the reported macOS setup without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, macos
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100