Clang crash when compiling the game using my game engine with c++20 module.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Hi, clang have some undefined behaviour with c++20 modules, one day everything compiles fine and suddenly it crash...
I use the following libs in my game engine : vulkan, mesh_optimizer, Entt, boost, stb_image, gli. You can find my CMakeFiles configuration on the repository of my game engine, located here : https://github.com/LaurentDuroisin7601/ODFAEG.
Here is the stack trace in CLion.
```
====================[ Build | MyGame | Release ]================================
/usr/local/bin/cmake --build /home/laurent/odfaeg2-master/TestODFAEG2/cmake-build-release --target MyGame -j 4
[1/2] Building CXX object CMakeFiles/MyGame.dir/main.cpp.o
FAILED: [code=1] CMakeFiles/MyGame.dir/main.cpp.o
/usr/bin/clang++ -DODFAEG_INSTALL_DIR=\"/home/laurent/odfaeg-install\" -isystem /home/laurent/odfaeg-install/include -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Core -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Math -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Window -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Physics -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Entity -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Graphics -m64 -O3 -DNDEBUG -std=gnu++20 -fcolor-diagnostics -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Core -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Math -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Window -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Physics -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Entity -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Graphics -MD -MT CMakeFiles/MyGame.dir/main.cpp.o -MF CMakeFiles/MyGame.dir/main.cpp.o.d @CMakeFiles/MyGame.dir/main.cpp.o.modmap -o CMakeFiles/MyGame.dir/main.cpp.o -c /home/laurent/odfaeg2-master/TestODFAEG2/main.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++ -DODFAEG_INSTALL_DIR=\"/home/laurent/odfaeg-install\" -isystem /home/laurent/odfaeg-install/include -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Core -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Math -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Window -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Physics -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Entity -isystem /home/laurent/odfaeg-install/share/odfaeg/modules/Graphics -m64 -O3 -DNDEBUG -std=gnu++20 -fcolor-diagnostics -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Core -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Math -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Window -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Physics -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Entity -fprebuilt-module-path=/home/laurent/odfaeg-install/share/odfaeg/pcm/Graphics -MD -MT CMakeFiles/MyGame.dir/main.cpp.o -MF CMakeFiles/MyGame.dir/main.cpp.o.d @CMakeFiles/MyGame.dir/main.cpp.o.modmap -o CMakeFiles/MyGame.dir/main.cpp.o -c /home/laurent/odfaeg2-master/TestODFAEG2/main.cpp
1. /home/laurent/odfaeg2-master/TestODFAEG2/main.cpp:52:33: current parser token ')'
2. /home/laurent/odfaeg2-master/TestODFAEG2/main.cpp:29:12: parsing function body 'main'
3. /home/laurent/odfaeg2-master/TestODFAEG2/main.cpp:29:12: in compound statement ('{}')
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 libLLVM.so.18.1 0x00007f7e51fa63bf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63
1 libLLVM.so.18.1 0x00007f7e51fa44f9 llvm::sys::RunSignalHandlers() + 89
2 libLLVM.so.18.1 0x00007f7e51ef0227
3 libc.so.6 0x00007f7e50a45330
4 libclang-cpp.so.18.1 0x00007f7e5a2e541e clang::Sema::diagnoseMissingImport(clang::SourceLocation, clang::NamedDecl const*, clang::SourceLocation, llvm::ArrayRef, clang::Sema::MissingImportKind, bool) + 302
5 libclang-cpp.so.18.1 0x00007f7e5a2e4f27 clang::Sema::diagnoseMissingImport(clang::SourceLocation, clang::NamedDecl const*, clang::Sema::MissingImportKind, bool) + 391
6 libclang-cpp.so.18.1 0x00007f7e5a2e4974 clang::Sema::diagnoseTypo(clang::TypoCorrection const&, clang::PartialDiagnostic const&, clang::PartialDiagnostic const&, bool) + 196
7 libclang-cpp.so.18.1 0x00007f7e5a2e4842 clang::Sema::diagnoseTypo(clang::TypoCorrection const&, clang::PartialDiagnostic const&, bool) + 66
8 libclang-cpp.so.18.1 0x00007f7e5a0f46c0 clang::Sema::ConvertArgumentsForCall(clang::CallExpr*, clang::Expr*, clang::FunctionDecl*, clang::FunctionProtoType const*, llvm::ArrayRef, clang::SourceLocation, bool) + 3536
9 libclang-cpp.so.18.1 0x00007f7e5a3e41c2 clang::Sema::BuildCallToMemberFunction(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) + 5170
10 libclang-cpp.so.18.1 0x00007f7e5a0f60a1 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*) + 81
11 libclang-cpp.so.18.1 0x00007f7e595e1b3f clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult) + 5391
12 libclang-cpp.so.18.1 0x00007f7e595e51c8 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) + 10008
13 libclang-cpp.so.18.1 0x00007f7e595dec24 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 276
14 libclang-cpp.so.18.1 0x00007f7e595deaf2 clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 18
15 libclang-cpp.so.18.1 0x00007f7e59641239 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) + 73
16 libclang-cpp.so.18.1 0x00007f7e5963f471 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) + 1073
17 libclang-cpp.so.18.1 0x00007f7e5963edfc clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) + 332
18 libclang-cpp.so.18.1 0x00007f7e59647aa2 clang::Parser::ParseCompoundStatementBody(bool) + 1618
19 libclang-cpp.so.18.1 0x00007f7e59648b77 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 183
20 libclang-cpp.so.18.1 0x00007f7e596640c7 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 3751
21 libclang-cpp.so.18.1 0x00007f7e595ad2a1 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 4689
22 libclang-cpp.so.18.1 0x00007f7e5966307f clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 1087
23 libclang-cpp.so.18.1 0x00007f7e59662a39 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 489
24 libclang-cpp.so.18.1 0x00007f7e59661c65 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 2197
25 libclang-cpp.so.18.1 0x00007f7e5965ff7b clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) + 1499
26 libclang-cpp.so.18.1 0x00007f7e5959747e clang::ParseAST(clang::Sema&, bool, bool) + 766
27 libclang-cpp.so.18.1 0x00007f7e5b40662c clang::FrontendAction::Execute() + 92
28 libclang-cpp.so.18.1 0x00007f7e5b3830b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 708
29 libclang-cpp.so.18.1 0x00007f7e5b48263d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 765
30 clang++ 0x00005b8c2938d42e cc1_main(llvm::ArrayRef, char const*, void*) + 3694
31 clang++ 0x00005b8c2938a894
32 libclang-cpp.so.18.1 0x00007f7e5b033972
33 libLLVM.so.18.1 0x00007f7e51eeff77 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) + 151
34 libclang-cpp.so.18.1 0x00007f7e5b033237 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const + 407
35 libclang-cpp.so.18.1 0x00007f7e5affb518 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 888
36 libclang-cpp.so.18.1 0x00007f7e5affb77f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const + 159
37 libclang-cpp.so.18.1 0x00007f7e5b017c20 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) + 352
38 clang++ 0x00005b8c2938a1ec clang_main(int, char**, llvm::ToolContext const&) + 11180
39 clang++ 0x00005b8c29397383 main + 131
40 libc.so.6 0x00007f7e50a2a1ca
41 libc.so.6 0x00007f7e50a2a28b __libc_start_main + 139
42 clang++ 0x00005b8c29387255 _start + 37
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 18.1.3 (1ubuntu1)
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/main-252fe8.cpp
clang++: note: diagnostic msg: /tmp/main-252fe8.sh
clang++: note: diagnostic msg:
********************
ninja: build stopped: subcommand failed.
It told me to attach some files to the issue, here they are :
```
[main-252fe8.cpp](https://github.com/user-attachments/files/28466295/main-252fe8.cpp)
[main-252fe8.sh](https://github.com/user-attachments/files/28466294/main-252fe8.sh)
Contributor guide
Assessment
This issue has not been assessed yet.