Issue 176649
Summary [C++20] [Modules] Assertion `IsPrivate && "inconsistent headers and roles"' failed.
Labels clang:modules, crash-on-invalid
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/4eYsd7M1E
```cpp
module M;
#include __FILE__
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Lex/ModuleMap.cpp:475: bool violatesPrivateInclude(clang::Module*, const clang::FileEntry*, clang::ModuleMap::KnownHeader): Assertion `IsPrivate && "inconsistent headers and roles"' 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/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++2a <source>
1.	<source>:2:2: current parser token 'include'
 #0 0x000000000430d598 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x430d598)
 #1 0x000000000430a9f4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x430a9f4)
 #2 0x000000000424ccc8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000788c5e042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000788c5e0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000788c5e042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x0000788c5e0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000788c5e02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x0000788c5e039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000084754c5 clang::ModuleMap::diagnoseHeaderInclusion(clang::Module*, bool, clang::SourceLocation, llvm::StringRef, clang::FileEntryRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x84754c5)
#10 0x000000000849bce6 clang::Preprocessor::LookupHeaderIncludeOrImport(clang::detail::SearchDirIteratorImpl<true>*, llvm::StringRef&, clang::SourceLocation, clang::CharSourceRange, clang::Token const&, bool&, bool, bool&, clang::detail::SearchDirIteratorImpl<true>, clang::FileEntry const*, llvm::StringRef&, llvm::SmallVectorImpl<char>&, llvm::SmallVectorImpl<char>&, clang::ModuleMap::KnownHeader&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x849bce6)
#11 0x000000000849ec03 clang::Preprocessor::HandleHeaderIncludeOrImport(clang::SourceLocation, clang::Token&, clang::Token&, clang::SourceLocation, clang::detail::SearchDirIteratorImpl<true>, clang::FileEntry const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x849ec03)
#12 0x00000000084a193d clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token&, clang::detail::SearchDirIteratorImpl<true>, clang::FileEntry const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x84a193d)
#13 0x00000000084a2980 clang::Preprocessor::HandleDirective(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x84a2980)
#14 0x000000000843dfda clang::Lexer::LexTokenInternal(clang::Token&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x843dfda)
#15 0x000000000844029e clang::Lexer::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x844029e)
#16 0x00000000084e782c clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x84e782c)
#17 0x0000000006a6e4f6 clang::Parser::ExpectAndConsumeSemi(unsigned int, llvm::StringRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a6e4f6)
#18 0x0000000006a6e726 clang::Parser::ParseModuleDecl(clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a6e726)
#19 0x0000000006a728c6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a728c6)
#20 0x0000000006a536ea clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a536ea)
#21 0x0000000004c75558 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c75558)
#22 0x0000000004f6f965 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f6f965)
#23 0x0000000004eef33e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4eef33e)
#24 0x000000000506a5dd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x506a5dd)
#25 0x0000000000ddd1de cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xddd1de)
#26 0x0000000000dd3baa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#27 0x0000000000dd3d2d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#28 0x0000000004ce8a99 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::'lambda'()>(long) Job.cpp:0:0
#29 0x000000000424d164 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x424d164)
#30 0x0000000004ce90af clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#31 0x0000000004ca9a82 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ca9a82)
#32 0x0000000004caaa2e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4caaa2e)
#33 0x0000000004cb1e75 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4cb1e75)
#34 0x0000000000dd9551 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdd9551)
#35 0x0000000000c96bf4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc96bf4)
#36 0x0000788c5e029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x0000788c5e029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000dd3645 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdd3645)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

It appears to have been crashing ever since C++20 was first supported in Clang.
https://godbolt.org/z/6csEfxc71
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to