llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.99k stars 11.95k forks source link

clang segfault #58254

Open rnikander opened 2 years ago

rnikander commented 2 years ago

I'm using clangd on a C++ project and it was crashing. Below I invoked clang++ directly from the command line to get the error report. If this isn't enough info to be useful, I'm sorry, but I don't want to attach my source code as the message at the bottom suggests.

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: /Users/rob/Dev/clang+llvm-15.0.1-x86_64-apple-darwin/bin/clang++ --driver-mode=g++ -DDEBUG -I/Users/rob/Dev/metal-cpp-beta -I/Users/rob/Dev/json_nlohmann/include/include -I/Users/rob/Workspace/Memogu/DocEditor -I/usr/local/opt/icu4c/include -I/Users/rob/Workspace/Memogu/Common -I/Users/rob/Workspace/Memogu/EncodiaDataStructures -I/Users/rob/Workspace/Memogu/MyUILib -I/Users/rob/Workspace/Memogu/AppleInterop -isystem /Users/rob/Workspace/Memogu/build-debug/vcpkg_installed/x64-osx/include -isystem /Users/rob/Workspace/Memogu/build-debug/vcpkg_installed/x64-osx/include/stduuid -Wall -Wimplicit-fallthrough -Werror=return-type -Wno-unused-variable -Wno-unused-function -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -std=gnu++2b -o DocEditor/CMakeFiles/DocEditor.dir/DocEditor/BlockElt.cc.o -c -resource-dir=/Users/rob/Dev/clang+llvm-15.0.1-x86_64-apple-darwin/lib/clang/15.0.1 -- /Users/rob/Workspace/Memogu/DocEditor/DocEditor/BlockElt.cc
1.  /Users/rob/Workspace/Memogu/DocEditor/DocEditor/BlockElt.cc:677:1: current parser token 'double'
2.  /Users/rob/Workspace/Memogu/DocEditor/DocEditor/BlockElt.cc:494:65: parsing function body 'BlockElt::layoutCoreTextFlow'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang-15                 0x0000000103480f7e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 46
1  clang-15                 0x000000010347fe18 llvm::sys::RunSignalHandlers() + 248
2  clang-15                 0x00000001034804f2 llvm::sys::CleanupOnSignal(unsigned long) + 210
3  clang-15                 0x00000001033a5a7f CrashRecoverySignalHandler(int) + 191
4  libsystem_platform.dylib 0x00007ff802cf9c1d _sigtramp + 29
5  libsystem_platform.dylib 0xfffffffffffff000 _sigtramp + 18446603370533770240
6  clang-15                 0x0000000105d5bb73 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) + 195
7  clang-15                 0x0000000105d5b82b clang::Expr::EvaluateAsConstantExpr(clang::Expr::EvalResult&, clang::ASTContext const&, clang::Expr::ConstantExprKind) const + 731
8  clang-15                 0x000000010555fb89 clang::Sema::PopExpressionEvaluationContext() + 1145
9  clang-15                 0x00000001053f9ff8 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) + 6680
10 clang-15                 0x00000001051ca9dd clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 269
11 clang-15                 0x00000001051e711e clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 3822
12 clang-15                 0x0000000105126e51 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 5297
13 clang-15                 0x00000001051e5ecc clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 828
14 clang-15                 0x00000001051e5985 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 437
15 clang-15                 0x00000001051e45b7 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 2007
16 clang-15                 0x00000001051e23fc clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 1004
17 clang-15                 0x000000010510986e clang::ParseAST(clang::Sema&, bool, bool) + 670
18 clang-15                 0x0000000103eb5b3a clang::FrontendAction::Execute() + 90
19 clang-15                 0x0000000103e28736 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 838
20 clang-15                 0x0000000103f368eb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 683
21 clang-15                 0x0000000101328237 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2087
22 clang-15                 0x0000000101326348 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 280
23 clang-15                 0x0000000103c58a97 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_1>(long) + 23
24 clang-15                 0x00000001033a57c3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 227
25 clang-15                 0x0000000103c58623 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const + 387
26 clang-15                 0x0000000103c1eaad clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 1085
27 clang-15                 0x0000000103c1ed20 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const + 144
28 clang-15                 0x0000000103c3adaf clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) + 863
29 clang-15                 0x00000001013259e9 clang_main(int, char**) + 10585
30 dyld                     0x00007ff80299e310 start + 2432
clang-15: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 15.0.1 (https://github.com/tru/llvm-release-build 33b6cbead48e63164b3e7c5ac9d34505c0391552)
Target: x86_64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Users/rob/Dev/clang+llvm-15.0.1-x86_64-apple-darwin/bin
clang-15: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-15: note: diagnostic msg: /var/folders/zm/mzv_wcgn0gn4xcj3z6vl4_cm0000gn/T/BlockElt-9135e8.cpp
clang-15: note: diagnostic msg: /var/folders/zm/mzv_wcgn0gn4xcj3z6vl4_cm0000gn/T/BlockElt-9135e8.sh
clang-15: note: diagnostic msg: Crash backtrace is located in
clang-15: note: diagnostic msg: /Users/rob/Library/Logs/DiagnosticReports/clang-15_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang-15: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang-15: note: diagnostic msg: 
shafik commented 2 years ago

This might be related to: https://github.com/llvm/llvm-project/issues/55183

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-frontend

cor3ntin commented 9 months ago

Unfortunately, we cannot meaningfully fix issues without a reproduction. Tools like creduce can be used to minimizing crashing source codes containing private informations https://github.com/csmith-project/creduce