llvm / llvm-project

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

Crash with assertion failure when compiling c++20 module #96693

Open ottojo opened 1 week ago

ottojo commented 1 week ago

I was playing around with C++20 modules and came across this crash when trying to include simdjson. Notably this only appeared when i switched to clang18, compilation under clang17 failed for other reason (without crash).

FAILED: Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o Profiler/CMakeFiles/profilerLib.dir/profiler.scope.pcm 
/opt/clang/18.1.8/bin/clang++ -DSIMDJSON_DISABLE_DEPRECATED_API=1 -DSIMDJSON_THREADS_ENABLED=1 -I/home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include -g -std=gnu++20 -fcolor-diagnostics -Wall -Wextra -Wpedantic -MD -MT Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o -MF Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o.d @Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o.modmap -o Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o -c /home/jonas/Workspace/ModuleTest/Profiler/modules/Scope.cppm
clang-18: /home/jonas/.cache/yay/clang-prefixed-release/src/llvm-project-llvmorg-18.1.8/clang/include/clang/AST/Decl.h:4976: void clang::Redeclarable<clang::FunctionDecl>::setPreviousDecl(decl_type *) [decl_type = clang::FunctionDecl]: Assertion `!isa<NamedDecl>(static_cast<decl_type*>(this)) || cast<NamedDecl>(static_cast<decl_type*>(this))->isLinkageValid()' 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/clang/18.1.8/bin/clang-18 -cc1 -triple x86_64-unknown-linux-gnu -emit-module-interface -disable-free -clear-ast-before-backend -main-file-name Scope.cppm -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18 -fcoverage-compilation-dir=/home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18 -resource-dir /opt/clang/18.1.8/lib/clang/18 -dependency-file Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o.d -MT Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o -sys-header-deps -module-file-deps -D SIMDJSON_DISABLE_DEPRECATED_API=1 -D SIMDJSON_THREADS_ENABLED=1 -I /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/backward -internal-isystem /opt/clang/18.1.8/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -Wpedantic -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o Profiler/CMakeFiles/profilerLib.dir/profiler.scope.pcm -x c++ /home/jonas/Workspace/ModuleTest/Profiler/modules/Scope.cppm
1.  /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:136:222: current parser token ';'
2.  /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:10:1: parsing namespace 'simdjson'
3.  /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:11:1: parsing namespace 'simdjson::fallback'
4.  /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:12:1: parsing namespace 'simdjson::fallback::ondemand'
5.  /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:20:1: parsing struct/union/class body 'simdjson::fallback::ondemand::token_iterator'
#0 0x0000776d4e624767 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/clang/18.1.8/bin/../lib/libLLVM.so.18.1+0x3e24767)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 18.1.8 (https://aur.archlinux.org/clang-prefixed-release.git 5b99959cda7596f74533734675cdc4796a2653c4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/clang/18.1.8/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/Scope-ed983e.cppm
clang++: note: diagnostic msg: /tmp/Scope-ed983e.sh
clang++: note: diagnostic msg: 

********************

Scope-ed983e.cppm.txt Scope-ed983e.sh.txt

edit: for reference, since the preprocessed sources are huge, the input file just looks like this :D

module;

#include <simdjson.h>

export module profiler.scope;

export enum class Scope { Global, Process, Thread };
llvmbot commented 1 week ago

@llvm/issue-subscribers-clang-modules

Author: Jonas Otto (ottojo)

I was playing around with C++20 modules and came across this crash when trying to include simdjson. Notably this only appeared when i switched to clang18, compilation under clang17 failed for other reason (without crash). ``` FAILED: Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o Profiler/CMakeFiles/profilerLib.dir/profiler.scope.pcm /opt/clang/18.1.8/bin/clang++ -DSIMDJSON_DISABLE_DEPRECATED_API=1 -DSIMDJSON_THREADS_ENABLED=1 -I/home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include -g -std=gnu++20 -fcolor-diagnostics -Wall -Wextra -Wpedantic -MD -MT Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o -MF Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o.d @Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o.modmap -o Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o -c /home/jonas/Workspace/ModuleTest/Profiler/modules/Scope.cppm clang-18: /home/jonas/.cache/yay/clang-prefixed-release/src/llvm-project-llvmorg-18.1.8/clang/include/clang/AST/Decl.h:4976: void clang::Redeclarable<clang::FunctionDecl>::setPreviousDecl(decl_type *) [decl_type = clang::FunctionDecl]: Assertion `!isa<NamedDecl>(static_cast<decl_type*>(this)) || cast<NamedDecl>(static_cast<decl_type*>(this))->isLinkageValid()' 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/clang/18.1.8/bin/clang-18 -cc1 -triple x86_64-unknown-linux-gnu -emit-module-interface -disable-free -clear-ast-before-backend -main-file-name Scope.cppm -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18 -fcoverage-compilation-dir=/home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18 -resource-dir /opt/clang/18.1.8/lib/clang/18 -dependency-file Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o.d -MT Profiler/CMakeFiles/profilerLib.dir/modules/Scope.cppm.o -sys-header-deps -module-file-deps -D SIMDJSON_DISABLE_DEPRECATED_API=1 -D SIMDJSON_THREADS_ENABLED=1 -I /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/backward -internal-isystem /opt/clang/18.1.8/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -Wpedantic -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o Profiler/CMakeFiles/profilerLib.dir/profiler.scope.pcm -x c++ /home/jonas/Workspace/ModuleTest/Profiler/modules/Scope.cppm 1. /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:136:222: current parser token ';' 2. /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:10:1: parsing namespace 'simdjson' 3. /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:11:1: parsing namespace 'simdjson::fallback' 4. /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:12:1: parsing namespace 'simdjson::fallback::ondemand' 5. /home/jonas/Workspace/ModuleTest/cmake-build-debug-clang-18/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:20:1: parsing struct/union/class body 'simdjson::fallback::ondemand::token_iterator' #0 0x0000776d4e624767 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/clang/18.1.8/bin/../lib/libLLVM.so.18.1+0x3e24767) clang++: error: unable to execute command: Aborted (core dumped) clang++: error: clang frontend command failed due to signal (use -v to see invocation) clang version 18.1.8 (https://aur.archlinux.org/clang-prefixed-release.git 5b99959cda7596f74533734675cdc4796a2653c4) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/clang/18.1.8/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/Scope-ed983e.cppm clang++: note: diagnostic msg: /tmp/Scope-ed983e.sh clang++: note: diagnostic msg: ******************** ``` [Scope-ed983e.cppm.txt](https://github.com/user-attachments/files/15978031/Scope-ed983e.cppm.txt) [Scope-ed983e.sh.txt](https://github.com/user-attachments/files/15978032/Scope-ed983e.sh.txt) edit: for reference, since the preprocessed sources are huge, the input file just looks like this :D ```c++ module; #include <simdjson.h> export module profiler.scope; export enum class Scope { Global, Process, Thread }; ```
ChuanqiXu9 commented 1 week ago

As I may not be able to debug this immediately, would you like to test this again with trunk in debug version? A complete stack trace may be helpful too.

ottojo commented 1 week ago

I did build main at 8ab66775dc885f7a99ee5f53771ce555e42085f9, and found the curious behavior that the build now succeeds when building clang in RelWithDebInfo mode, and still fails in Debug? Although i dont have much confidence that everything was built correctly, as i did run out of disk space while compiling...

In any case, there might still be some issue hidden so here is the data from the crash in debug mode:

Stack trace ``` FAILED: Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o Profiler/CMakeFiles/test_lib.dir/profiler.scope.pcm /home/jonas/Workspace/llvm-project/build-debug/bin/clang++ -DSIMDJSON_DISABLE_DEPRECATED_API=1 -DSIMDJSON_THREADS_ENABLED=1 -I/home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include -g -std=gnu++20 -fcolor-diagnostics -MD -MT Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o -MF Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o.d @Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o.modmap -o Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o -c /home/jonas/Workspace/ModuleTest/Profiler/test_lib.cppm clang-19: /home/jonas/Workspace/llvm-project/clang/include/clang/AST/Decl.h:5041: void clang::Redeclarable::setPreviousDecl(decl_type*) [with decl_type = clang::FunctionDecl]: Assertion `!isa(static_cast(this)) || cast(static_cast(this))->isLinkageValid()' 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: /home/jonas/Workspace/llvm-project/build-debug/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-module-interface -disable-free -clear-ast-before-backend -main-file-name test_lib.cppm -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug -fcoverage-compilation-dir=/home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug -resource-dir /home/jonas/Workspace/llvm-project/build-debug/lib/clang/19 -dependency-file Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o.d -MT Profiler/CMakeFiles/test_lib.dir/test_lib.cppm.o -sys-header-deps -module-file-deps -D SIMDJSON_DISABLE_DEPRECATED_API=1 -D SIMDJSON_THREADS_ENABLED=1 -I /home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/backward -internal-isystem /home/jonas/Workspace/llvm-project/build-debug/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o Profiler/CMakeFiles/test_lib.dir/profiler.scope.pcm -x c++ /home/jonas/Workspace/ModuleTest/Profiler/test_lib.cppm 1. /home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:136:222: current parser token ';' 2. /home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:10:1: parsing namespace 'simdjson' 3. /home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:11:1: parsing namespace 'simdjson::fallback' 4. /home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:12:1: parsing namespace 'simdjson::fallback::ondemand' 5. /home/jonas/Workspace/ModuleTest/cmake-build-debug-local-clang-debug/_deps/simdjson-src/include/simdjson/generic/ondemand/token_iterator.h:20:1: parsing struct/union/class body 'simdjson::fallback::ondemand::token_iterator' #0 0x00006205108dbbbe llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/jonas/Workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22 #1 0x00006205108dbfd1 PrintStackTraceSignalHandler(void*) /home/jonas/Workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1 #2 0x00006205108d9485 llvm::sys::RunSignalHandlers() /home/jonas/Workspace/llvm-project/llvm/lib/Support/Signals.cpp:105:20 #3 0x00006205108db49b SignalHandler(int) /home/jonas/Workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1 #4 0x00007d6f4db65ae0 (/usr/lib/libc.so.6+0x3cae0) #5 0x00007d6f4dbbde44 (/usr/lib/libc.so.6+0x94e44) #6 0x00007d6f4db65a30 raise (/usr/lib/libc.so.6+0x3ca30) #7 0x00007d6f4db4d4c3 abort (/usr/lib/libc.so.6+0x244c3) #8 0x00007d6f4db4d3df (/usr/lib/libc.so.6+0x243df) #9 0x00007d6f4db5dc67 (/usr/lib/libc.so.6+0x34c67) #10 0x00006205168e528e clang::Redeclarable::setPreviousDecl(clang::FunctionDecl*) /home/jonas/Workspace/llvm-project/clang/include/clang/AST/Decl.h:5043:1 #11 0x0000620516abb24f clang::FunctionDecl::setPreviousDeclaration(clang::FunctionDecl*) /home/jonas/Workspace/llvm-project/clang/lib/AST/Decl.cpp:3602:67 #12 0x0000620514fac845 clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) /home/jonas/Workspace/llvm-project/clang/lib/Sema/SemaDecl.cpp:12226:34 #13 0x0000620514fa57a0 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef, bool&) /home/jonas/Workspace/llvm-project/clang/lib/Sema/SemaDecl.cpp:10694:25 #14 0x00006205151094af clang::Sema::ActOnFriendFunctionDecl(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef) /home/jonas/Workspace/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:18014:42 #15 0x0000620514b8d9fa clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3233:49 #16 0x0000620514c5515e clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseTemplate.cpp:210:42 #17 0x0000620514c54f7d clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseTemplate.cpp:178:39 #18 0x0000620514b8c77c clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:2930:52 #19 0x0000620514b8f539 clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributes&, clang::TypeSpecifierType, clang::Decl*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3620:42 #20 0x0000620514b90310 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3826:30 #21 0x0000620514b89ed1 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:2304:34 #22 0x0000620514b61c2f clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDecl.cpp:4627:26 #23 0x0000620514b31f1f clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) /home/jonas/Workspace/llvm-project/clang/include/clang/Parse/Parser.h:2505:38 #24 0x0000620514b26b4a clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:1158:26 #25 0x0000620514b273a9 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:1271:42 #26 0x0000620514b265fc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:1074:50 #27 0x0000620514b816d4 clang::Parser::ParseInnerNamespace(llvm::SmallVector const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:273:5 #28 0x0000620514b814ee clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:252:22 #29 0x0000620514b5781f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDecl.cpp:2008:26 #30 0x0000620514b260fc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:990:30 #31 0x0000620514b816d4 clang::Parser::ParseInnerNamespace(llvm::SmallVector const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:273:5 #32 0x0000620514b814ee clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:252:22 #33 0x0000620514b5781f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDecl.cpp:2008:26 #34 0x0000620514b260fc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:990:30 #35 0x0000620514b816d4 clang::Parser::ParseInnerNamespace(llvm::SmallVector const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:273:5 #36 0x0000620514b814ee clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:252:22 #37 0x0000620514b5781f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseDecl.cpp:2008:26 #38 0x0000620514b260fc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:990:30 #39 0x0000620514b25426 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) /home/jonas/Workspace/llvm-project/clang/lib/Parse/Parser.cpp:763:36 #40 0x0000620514b20641 clang::ParseAST(clang::Sema&, bool, bool) /home/jonas/Workspace/llvm-project/clang/lib/Parse/ParseAST.cpp:163:37 #41 0x0000620511a2b4e0 clang::ASTFrontendAction::ExecuteAction() /home/jonas/Workspace/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1192:11 #42 0x0000620511a2adda clang::FrontendAction::Execute() /home/jonas/Workspace/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1082:38 #43 0x000062051193dee9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/jonas/Workspace/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1061:42 #44 0x0000620511bdc66c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/jonas/Workspace/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:38 #45 0x000062050eaf235b cc1_main(llvm::ArrayRef, char const*, void*) /home/jonas/Workspace/llvm-project/clang/tools/driver/cc1_main.cpp:232:40 #46 0x000062050eae3e6f ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&) /home/jonas/Workspace/llvm-project/clang/tools/driver/driver.cpp:215:20 #47 0x000062050eae43a7 clang_main(int, char**, llvm::ToolContext const&) /home/jonas/Workspace/llvm-project/clang/tools/driver/driver.cpp:256:26 #48 0x000062050eb1c93e main /home/jonas/Workspace/llvm-project/build-debug/tools/clang/tools/driver/clang-driver.cpp:17:20 #49 0x00007d6f4db4ec88 (/usr/lib/libc.so.6+0x25c88) #50 0x00007d6f4db4ed4c __libc_start_main (/usr/lib/libc.so.6+0x25d4c) #51 0x000062050eae3225 _start (/home/jonas/Workspace/llvm-project/build-debug/bin/clang-19+0x10ab225) clang++: error: unable to execute command: Aborted (core dumped) clang++: error: clang frontend command failed due to signal (use -v to see invocation) clang version 19.0.0git (git@github.com:llvm/llvm-project.git 8ab66775dc885f7a99ee5f53771ce555e42085f9) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/jonas/Workspace/llvm-project/build-debug/bin Build config: +unoptimized, +assertions 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/test_lib-270a25.cppm clang++: note: diagnostic msg: /tmp/test_lib-270a25.sh clang++: note: diagnostic msg: ******************** ninja: build stopped: subcommand failed. ```

test_lib-270a25.cppm.txt test_lib-270a25.sh.txt

ChuanqiXu9 commented 1 week ago

I did build main at 8ab6677, and found the curious behavior that the build now succeeds when building clang in RelWithDebInfo mode, and still fails in Debug? Although i dont have much confidence that everything was built correctly, as i did run out of disk space while compiling...

The reason may be that the check only happens with assertion enabled. And assertions is not enabled by default with release builds. If you're playing with modules (instead of trying to make it in products), I think, maybe, you can continue the experiment with release builds without assertions.

ChuanqiXu9 commented 1 week ago

BTW, if you would like to contribute, maybe you can try to bisect to find where the problem shows up.

You said clang17 failed for other reasons. So it can't be bisected usually. Then you can bisect to find the commit that makes the other failure goes away. And in that time, if it builds correctly, then it is a regression. Otherwise, it may be a long-standing non-found issue. Then if you still want to dig in, you can try to reduce the reproducer you provide.

ChuanqiXu9 commented 1 week ago

Coincidently, I just met a pretty similar issue during the development. And I tried to fix that. Can you try to confirm if this fixes your problem?