| Issue |
208856
|
| Summary |
[clang][modules] Passing built module file from slightly different compilations leads to `Assertion 'LocalDeclID < LocalNumDecls' failed.`
|
| Labels |
|
| Assignees |
|
| Reporter |
davidstone
|
Given
```c++
module;
namespace std {}
export module a;
```
```c++
export module b;
import a;
```
```c++
import b;
```
Then after compiling with
```sh
clang++ -std=c++20 -x c++-module -fmodule-output=build/a.pcm -o /dev/null -c a.cpp
clang++ -std=c++20 -x c++-module -fmodule-output=build/a.bmi -o build/a.bmi --precompile a.cpp;
clang++ -std=c++20 -x c++-module -fmodule-output=build/b.pcm -fmodule-file="a=build/a.bmi" -o /dev/null -c b.cpp;
clang++ -std=c++20 -fmodule-file="b=build/b.pcm" -fmodule-file="a=build/a.pcm" -o /dev/null -c c.cpp
```
clang crashes with
```console
clang++: /home/david/llvm/clang/lib/Serialization/ASTReader.cpp:1097: static LocalDeclID clang::LocalDeclID::get(ASTReader &, ModuleFile &, DeclID): Assertion `LocalDeclID < LocalNumDecls' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: clang++ -std=c++20 -fmodule-file=b=build/b.pcm -fmodule-file=a=build/a.pcm -o /dev/null -c c.cpp
1. <eof> parser at end of file
#0 0x0000563f8317e8dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/david/llvm/build/bin/clang-23+0x4bc18dc)
#1 0x0000563f8317b4e1 llvm::sys::RunSignalHandlers() (/home/david/llvm/build/bin/clang-23+0x4bbe4e1)
#2 0x0000563f8317d326 llvm::sys::CleanupOnSignal(unsigned long) (/home/david/llvm/build/bin/clang-23+0x4bc0326)
#3 0x0000563f830a4e0d CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007fc13f63e270 (/usr/lib/libc.so.6+0x3e270)
#5 0x00007fc13f69981c (/usr/lib/libc.so.6+0x9981c)
#6 0x00007fc13f63e150 raise (/usr/lib/libc.so.6+0x3e150)
#7 0x00007fc13f62567d abort (/usr/lib/libc.so.6+0x2567d)
#8 0x00007fc13f6266fc (/usr/lib/libc.so.6+0x266fc)
#9 0x00007fc13f635ef2 __assert_fail (/usr/lib/libc.so.6+0x35ef2)
#10 0x0000563f84287d70 clang::LocalDeclID::get(clang::ASTReader&, clang::serialization::ModuleFile&, unsigned long) (/home/david/llvm/build/bin/clang-23+0x5ccad70)
#11 0x0000563f842aab77 clang::ASTReader::ReadDeclID(clang::serialization::ModuleFile&, llvm::SmallVectorImpl<unsigned long> const&, unsigned int&) (/home/david/llvm/build/bin/clang-23+0x5cedb77)
#12 0x0000563f842a670b clang::ASTReader::ReadASTBlock(clang::serialization::ModuleFile&, unsigned int) (/home/david/llvm/build/bin/clang-23+0x5ce970b)
#13 0x0000563f842acbbf clang::ASTReader::ReadAST(clang::ModuleFileName, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, clang::serialization::ModuleFile**) (/home/david/llvm/build/bin/clang-23+0x5cefbbf)
#14 0x0000563f8414eb0d clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, clang::SourceLocation, clang::SourceRange, bool) (/home/david/llvm/build/bin/clang-23+0x5b91b0d)
#15 0x0000563f84150fa2 clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<clang::IdentifierLoc>, clang::Module::NameVisibilityKind, bool) (/home/david/llvm/build/bin/clang-23+0x5b93fa2)
#16 0x0000563f857a5a24 clang::Sema::ActOnModuleImport(clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef<clang::IdentifierLoc>, bool) (/home/david/llvm/build/bin/clang-23+0x71e8a24)
#17 0x0000563f85218935 clang::Parser::ParseModuleImport(clang::SourceLocation, clang::Sema::ModuleImportState&) (/home/david/llvm/build/bin/clang-23+0x6c5b935)
#18 0x0000563f852176cd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/david/llvm/build/bin/clang-23+0x6c5a6cd)
#19 0x0000563f8521715f clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/david/llvm/build/bin/clang-23+0x6c5a15f)
#20 0x0000563f85120eea clang::ParseAST(clang::Sema&, bool, bool) (/home/david/llvm/build/bin/clang-23+0x6b63eea)
#21 0x0000563f841d4084 clang::FrontendAction::Execute() (/home/david/llvm/build/bin/clang-23+0x5c17084)
#22 0x0000563f84148919 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/david/llvm/build/bin/clang-23+0x5b8b919)
#23 0x0000563f84278368 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/david/llvm/build/bin/clang-23+0x5cbb368)
#24 0x0000563f81571024 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/david/llvm/build/bin/clang-23+0x2fb4024)
#25 0x0000563f8156ca89 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#26 0x0000563f8156f1a8 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000563f83f299f9 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::$_0>(long) Job.cpp:0:0
#28 0x0000563f830a4aee llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/david/llvm/build/bin/clang-23+0x4ae7aee)
#29 0x0000563f83f292f5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/david/llvm/build/bin/clang-23+0x596c2f5)
#30 0x0000563f83edd258 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/david/llvm/build/bin/clang-23+0x5920258)
#31 0x0000563f83ede148 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/david/llvm/build/bin/clang-23+0x5921148)
#32 0x0000563f83f07789 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/david/llvm/build/bin/clang-23+0x594a789)
#33 0x0000563f8156c2ab clang_main(int, char**, llvm::ToolContext const&) (/home/david/llvm/build/bin/clang-23+0x2faf2ab)
#34 0x0000563f8157d07f main (/home/david/llvm/build/bin/clang-23+0x2fc007f)
#35 0x00007fc13f627741 (/usr/lib/libc.so.6+0x27741)
#36 0x00007fc13f627879 __libc_start_main (/usr/lib/libc.so.6+0x27879)
#37 0x0000563f8156a365 _start (/home/david/llvm/build/bin/clang-23+0x2fad365)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 23.0.0git (https://github.com/llvm/llvm-project.git 54b5b78a6332a0faa13f2297a5b3751a1d7544a9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/david/llvm/build/bin
Build config: +assertions
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING CRASH REPRODUCER FILES TO THE BUG REPORT:
clang++: note: diagnostic msg: /tmp/c-8227e7.cpp
clang++: note: diagnostic msg: /tmp/c-8227e7.sh
clang++: note: diagnostic msg:
********************
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs