| Issue |
169629
|
| Summary |
crash on __builtin_snprintf with `-Weverything`
|
| Labels |
clang:frontend,
clang:diagnostics,
crash
|
| Assignees |
|
| Reporter |
k-arrows
|
Reproducer:
https://godbolt.org/z/qqYfvdPT7
```cpp
void foo(void) { int n = __builtin_snprintf(0, 0, "%"); }
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Basic/SourceManager.cpp:886: clang::FileID clang::SourceManager::getFileIDLoaded(clang::SourceLocation::UIntTy) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -Weverything <source>
1. <eof> parser at end of file
#0 0x00000000042589c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42589c8)
#1 0x0000000004255df4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4255df4)
#2 0x0000000004199b28 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000727b3a842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000727b3a8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000727b3a842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000727b3a8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000727b3a82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000727b3a839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000044b6123 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b6123)
#10 0x00000000044b80df (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b80df)
#11 0x00000000044bde0a clang::SourceManager::getDecomposedLoc(clang::SourceLocation) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44bde0a)
#12 0x00000000044c1342 clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c1342)
#13 0x00000000044b4281 clang::FullSourceLoc::getPresumedLoc(bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b4281)
#14 0x0000000004f74205 clang::DiagnosticRenderer::emitDiagnostic(clang::FullSourceLoc, clang::DiagnosticsEngine::Level, llvm::StringRef, llvm::ArrayRef<clang::CharSourceRange>, llvm::ArrayRef<clang::FixItHint>, llvm::PointerUnion<clang::Diagnostic const*, clang::StoredDiagnostic const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f74205)
#15 0x0000000004efd0c5 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4efd0c5)
#16 0x0000000004495030 clang::DiagnosticsEngine::Report(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4495030)
#17 0x0000000004495745 clang::DiagnosticsEngine::ProcessDiag(clang::DiagnosticBuilder const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4495745)
#18 0x0000000004495825 clang::DiagnosticsEngine::EmitDiagnostic(clang::DiagnosticBuilder const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4495825)
#19 0x0000000006ad64e6 clang::Sema::EmitDiagnostic(unsigned int, clang::DiagnosticBuilder const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ad64e6)
#20 0x0000000006b4bbc2 clang::SemaBase::ImmediateDiagBuilder::~ImmediateDiagBuilder() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b4bbc2)
#21 0x0000000006ac2f98 clang::SemaBase::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ac2f98)
#22 0x00000000075f0396 (anonymous namespace)::UnsafeBufferUsageReporter::handleUnsafeLibcCall(clang::CallExpr const*, unsigned int, clang::ASTContext&, clang::Expr const*) AnalysisBasedWarnings.cpp:0:0
#23 0x00000000077b6439 applyGadgets(clang::Decl const*, std::vector<std::unique_ptr<(anonymous namespace)::FixableGadget, std::default_delete<(anonymous namespace)::FixableGadget>>, std::allocator<std::unique_ptr<(anonymous namespace)::FixableGadget, std::default_delete<(anonymous namespace)::FixableGadget>>>>, std::vector<std::unique_ptr<(anonymous namespace)::WarningGadget, std::default_delete<(anonymous namespace)::WarningGadget>>, std::allocator<std::unique_ptr<(anonymous namespace)::WarningGadget, std::default_delete<(anonymous namespace)::WarningGadget>>>>, (anonymous namespace)::DeclUseTracker, clang::UnsafeBufferUsageHandler&, bool) UnsafeBufferUsage.cpp:0:0
#24 0x00000000077b9d23 clang::checkUnsafeBufferUsage(clang::Decl const*, clang::UnsafeBufferUsageHandler&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77b9d23)
#25 0x00000000075dac69 CallableVisitor::VisitFunctionDecl(clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75dac69)
#26 0x0000000007b17bd5 clang::DynamicRecursiveASTVisitorBase<false>::TraverseFunctionDecl(clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b17bd5)
#27 0x0000000007acd6dc clang::RecursiveASTVisitor<(anonymous namespace)::Impl<false>>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) DynamicRecursiveASTVisitor.cpp:0:0
#28 0x0000000007ae93ec clang::DynamicRecursiveASTVisitorBase<false>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ae93ec)
#29 0x00000000075e125e clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::TranslationUnitDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75e125e)
#30 0x0000000006ae7ec6 clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ae7ec6)
#31 0x0000000006951345 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6951345)
#32 0x000000000693285a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x693285a)
#33 0x0000000004ba7698 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ba7698)
#34 0x0000000004e94c45 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e94c45)
#35 0x0000000004e14cce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e14cce)
#36 0x0000000004f8cf9d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f8cf9d)
#37 0x0000000000dc6d10 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc6d10)
#38 0x0000000000dbd78a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#39 0x0000000000dbd90d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#40 0x0000000004c0fbb9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#41 0x0000000004199fc4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4199fc4)
#42 0x0000000004c101cf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#43 0x0000000004bd0c92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd0c92)
#44 0x0000000004bd1c3e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd1c3e)
#45 0x0000000004bd9205 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd9205)
#46 0x0000000000dc3131 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc3131)
#47 0x0000000000c71b04 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc71b04)
#48 0x0000727b3a829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#49 0x0000727b3a829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#50 0x0000000000dbd225 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdbd225)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs