Issue |
99809
|
Summary |
Clang++ segfault on instantiating function definition
|
Labels |
clang
|
Assignees |
|
Reporter |
the-moisrex
|
GCC compiles this just fine. I'm not sure about previous versions of Clang, but I don't think previous versions had this crash. I believe I haven't touched anything in the `function_ref` utility recently.
Clang version:
```
clang version 18.1.8
Target: x86_64-pc-linux-gnu
Thread model: posix
```
The segfault:
```
FAILED: tests/CMakeFiles/test-functional.dir/functional_test.cpp.o
ccache /usr/bin/clang++ -DFMT_SHARED -DWEBPP_PROJECT_ROOT=/webpp -I/webpp/webpp -I/webpp/webpp/.. -I/include -I/webpp/build-dev-clang/_deps/fmt-src/include -I/webpp/build-dev-clang/_deps/liburing-src -isystem /webpp/build-dev-clang/_deps/rapidjson-src/include -isystem /webpp/build-dev-clang/_deps/googletest-src/googletest/include -isystem /webpp/build-dev-clang/_deps/googletest-src/googletest -g -g3 -Wall -Wpedantic -Wextra -Wconversion -Wshadow -O0 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -std=gnu++20 -fcolor-diagnostics -fcolor-diagnostics -Winvalid-pch -Xclang -include-pch -Xclang /webpp/build-dev-clang/tests/CMakeFiles/test-functional.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /webpp/build-dev-clang/tests/CMakeFiles/test-functional.dir/cmake_pch.hxx -MD -MT tests/CMakeFiles/test-functional.dir/functional_test.cpp.o -MF tests/CMakeFiles/test-functional.dir/functional_test.cpp.o.d @tests/CMakeFiles/test-functional.dir/functional_test.cpp.o.modmap -o tests/CMakeFiles/test-functional.dir/functional_test.cpp.o -c /webpp/tests/functional_test.cpp
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: /usr/bin/clang++ -DFMT_SHARED -DWEBPP_PROJECT_ROOT=/webpp -I/webpp/webpp -I/webpp/webpp/.. -I/include -I/webpp/build-dev-clang/_deps/fmt-src/include -I/webpp/build-dev-clang/_deps/liburing-src -isystem /webpp/build-dev-clang/_deps/rapidjson-src/include -isystem /webpp/build-dev-clang/_deps/googletest-src/googletest/include -isystem /webpp/build-dev-clang/_deps/googletest-src/googletest -g -g3 -Wall -Wpedantic -Wextra -Wconversion -Wshadow -O0 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -std=gnu++20 -fcolor-diagnostics -fcolor-diagnostics -Winvalid-pch -Xclang -include-pch -Xclang /webpp/build-dev-clang/tests/CMakeFiles/test-functional.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /webpp/build-dev-clang/tests/CMakeFiles/test-functional.dir/cmake_pch.hxx -MD -MT tests/CMakeFiles/test-functional.dir/functional_test.cpp.o -MF tests/CMakeFiles/test-functional.dir/functional_test.cpp.o.d @tests/CMakeFiles/test-functional.dir/functional_test.cpp.o.modmap -o tests/CMakeFiles/test-functional.dir/functional_test.cpp.o -c /webpp/tests/functional_test.cpp
1. /webpp/tests/functional_test.cpp:276:37: current parser token ';'
2. /webpp/tests/functional_test.cpp:272:41: parsing function body 'FunctionalTests_FunctionRefTests_Test::TestBody'
3. /webpp/tests/functional_test.cpp:272:41: in compound statement ('{}')
4. /webpp/tests/../webpp/std/function_ref.hpp:328:35: instantiating function definition 'webpp::istl::function_ref<int ()>::function_ref<(lambda at /webpp/tests/functional_test.cpp:273:18)>'
#0 0x00007c1aeafc4d90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM.so.18.1+0x7c4d90)
#1 0x00007c1aeafc226d llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/libLLVM.so.18.1+0x7c226d)
#2 0x00007c1aeaea88e9 (/usr/lib/libLLVM.so.18.1+0x6a88e9)
#3 0x00007c1aea250ae0 (/usr/lib/libc.so.6+0x3cae0)
#4 0x00007c1af3ec8867 clang::Sema::CheckParameterPacksForExpansion(clang::SourceLocation, clang::SourceRange, llvm::ArrayRef<std::pair<llvm::PointerUnion<clang::TemplateTypeParmType const*, clang::NamedDecl*>, clang::SourceLocation>>, clang::MultiLevelTemplateArgumentList const&, bool&, bool&, std::optional<unsigned int>&) (/usr/lib/libclang-cpp.so.18.1+0x14c8867)
#5 0x00007c1af3e8ae91 (/usr/lib/libclang-cpp.so.18.1+0x148ae91)
#6 0x00007c1af3e8e4ef (/usr/lib/libclang-cpp.so.18.1+0x148e4ef)
#7 0x00007c1af3e8ef51 (/usr/lib/libclang-cpp.so.18.1+0x148ef51)
#8 0x00007c1af3e941f4 (/usr/lib/libclang-cpp.so.18.1+0x14941f4)
#9 0x00007c1af3e9473f clang::Sema::SubstExceptionSpec(clang::SourceLocation, clang::FunctionProtoType::ExceptionSpecInfo&, llvm::SmallVectorImpl<clang::QualType>&, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/libclang-cpp.so.18.1+0x149473f)
#10 0x00007c1af3e339aa clang::Sema::SubstituteExplicitTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo&, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, llvm::SmallVectorImpl<clang::QualType>&, clang::QualType*, clang::sema::TemplateDeductionInfo&) (/usr/lib/libclang-cpp.so.18.1+0x14339aa)
#11 0x00007c1af3e33ac9 (/usr/lib/libclang-cpp.so.18.1+0x1433ac9)
#12 0x00007c1af38063ad clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/libclang-cpp.so.18.1+0xe063ad)
#13 0x00007c1af3e70c73 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) (/usr/lib/libclang-cpp.so.18.1+0x1470c73)
#14 0x00007c1af3d37496 clang::Sema::ResolveAddressOfOverloadedFunction(clang::Expr*, clang::QualType, bool, clang::DeclAccessPair&, bool*) (/usr/lib/libclang-cpp.so.18.1+0x1337496)
#15 0x00007c1af3d38dfa (/usr/lib/libclang-cpp.so.18.1+0x1338dfa)
#16 0x00007c1af3d39e14 (/usr/lib/libclang-cpp.so.18.1+0x1339e14)
#17 0x00007c1af3d3a197 clang::Sema::TryImplicitConversion(clang::Expr*, clang::QualType, bool, clang::Sema::AllowedExplicit, bool, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0x133a197)
#18 0x00007c1af3c194c6 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0x12194c6)
#19 0x00007c1af3c252cd clang::Sema::CanPerformCopyInitialization(clang::InitializedEntity const&, clang::ActionResult<clang::Expr*, true>) (/usr/lib/libclang-cpp.so.18.1+0x12252cd)
#20 0x00007c1af3c25b51 (/usr/lib/libclang-cpp.so.18.1+0x1225b51)
#21 0x00007c1af51c8e76 (/usr/lib/libclang-cpp.so.18.1+0x27c8e76)
#22 0x00007c1af3c232fe (/usr/lib/libclang-cpp.so.18.1+0x12232fe)
#23 0x00007c1af3c239e2 (/usr/lib/libclang-cpp.so.18.1+0x12239e2)
#24 0x00007c1af3c18c73 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0x1218c73)
#25 0x00007c1af3a0df82 clang::Sema::BuildMemberInitializer(clang::ValueDecl*, clang::Expr*, clang::SourceLocation) (/usr/lib/libclang-cpp.so.18.1+0x100df82)
#26 0x00007c1af3ecea2a clang::Sema::InstantiateMemInitializers(clang::CXXConstructorDecl*, clang::CXXConstructorDecl const*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/libclang-cpp.so.18.1+0x14cea2a)
#27 0x00007c1af3edc010 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0x14dc010)
#28 0x00007c1af38063ad clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/libclang-cpp.so.18.1+0xe063ad)
#29 0x00007c1af3ae762f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/usr/lib/libclang-cpp.so.18.1+0x10e762f)
#30 0x00007c1af3a39d73 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/usr/lib/libclang-cpp.so.18.1+0x1039d73)
#31 0x00007c1af3a40299 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/usr/lib/libclang-cpp.so.18.1+0x1040299)
#32 0x00007c1af3c1f39f clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/usr/lib/libclang-cpp.so.18.1+0x121f39f)
#33 0x00007c1af398fb51 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/usr/lib/libclang-cpp.so.18.1+0xf8fb51)
#34 0x00007c1af2f9bb12 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/usr/lib/libclang-cpp.so.18.1+0x59bb12)
#35 0x00007c1af2fc1249 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/libclang-cpp.so.18.1+0x5c1249)
#36 0x00007c1af2fd93e4 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/usr/lib/libclang-cpp.so.18.1+0x5d93e4)
#37 0x00007c1af2fd982a clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/libclang-cpp.so.18.1+0x5d982a)
#38 0x00007c1af305964c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/libclang-cpp.so.18.1+0x65964c)
#39 0x00007c1af305a1e8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/libclang-cpp.so.18.1+0x65a1e8)
#40 0x00007c1af305fa6a clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/libclang-cpp.so.18.1+0x65fa6a)
#41 0x00007c1af3061a24 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/libclang-cpp.so.18.1+0x661a24)
#42 0x00007c1af3062b5f clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/libclang-cpp.so.18.1+0x662b5f)
#43 0x00007c1af2fc1590 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/libclang-cpp.so.18.1+0x5c1590)
#44 0x00007c1af304c7cb clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.18.1+0x64c7cb)
#45 0x00007c1af30653d2 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/libclang-cpp.so.18.1+0x6653d2)
#46 0x00007c1af3065fdb clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/libclang-cpp.so.18.1+0x665fdb)
#47 0x00007c1af2f89ec0 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0x589ec0)
#48 0x00007c1af4a1a7c1 clang::FrontendAction::Execute() (/usr/lib/libclang-cpp.so.18.1+0x201a7c1)
#49 0x00007c1af49bbad7 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/libclang-cpp.so.18.1+0x1fbbad7)
#50 0x00007c1af4a6e11d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/libclang-cpp.so.18.1+0x206e11d)
#51 0x00006421ef985284 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang+++0x13284)
#52 0x00006421ef9895ba (/usr/bin/clang+++0x175ba)
#53 0x00007c1af46f7175 (/usr/lib/libclang-cpp.so.18.1+0x1cf7175)
#54 0x00007c1aeaea8d3a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/libLLVM.so.18.1+0x6a8d3a)
#55 0x00007c1af46f9aa6 (/usr/lib/libclang-cpp.so.18.1+0x1cf9aa6)
#56 0x00007c1af46b5529 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/libclang-cpp.so.18.1+0x1cb5529)
#57 0x00007c1af46b591c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/libclang-cpp.so.18.1+0x1cb591c)
#58 0x00007c1af46d38c4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/libclang-cpp.so.18.1+0x1cd38c4)
#59 0x00006421ef98bebd clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang+++0x19ebd)
#60 0x00006421ef97cfb5 main (/usr/bin/clang+++0xafb5)
#61 0x00007c1aea239c88 (/usr/lib/libc.so.6+0x25c88)
#62 0x00007c1aea239d4c __libc_start_main (/usr/lib/libc.so.6+0x25d4c)
#63 0x00006421ef97d015 _start (/usr/bin/clang+++0xb015)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.8
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/functional_test-e6adfa.cpp
clang++: note: diagnostic msg: /tmp/functional_test-e6adfa.sh
clang++: note: diagnostic msg:
********************
ninja: build stopped: subcommand failed.
```
[functional_test-e6adfa.cpp.log](https://github.com/user-attachments/files/16324040/functional_test-e6adfa.cpp.log)
[functional_test-e6adfa.sh.log](https://github.com/user-attachments/files/16324041/functional_test-e6adfa.sh.log)
[The linked source code on Github](https://github.com/the-moisrex/webpp/blob/f9d3d83908a2bc01b6c6cf82e13a160be2cdc9f9/webpp/std/function_ref.hpp#L328)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs