Open
Description
A min reproducible example:
https://github.com/RichardLuo0/clang-bug-pch-and-module
Even if the PCH isn't used, it still crashes.
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: C:/dev/msys2/clang64/bin/clang++.exe -cc1 -triple x86_64-w64-windows-gnu -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name module.cppm -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -fno-sized-deallocation -fno-use-init-array -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=C:/Users/Richard/Project/RepoTest/clang-bug-pch-and-module/build -fcoverage-compilation-dir=C:/Users/Richard/Project/RepoTest/clang-bug-pch-and-module/build -resource-dir C:/dev/msys2/clang64/lib/clang/19 -Wall -Winvalid-pch -std=gnu++23 -fdeprecated-macro -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fmodule-file=module2:part=CMakeFiles/main.dir/module2-part.pcm -fmodule-file=module1=CMakeFiles/main.dir/module1.pcm -fmodule-file=module1:part1=CMakeFiles/main.dir/module1-part1.pcm -fmodule-file=module1:part2=CMakeFiles/main.dir/module1-part2.pcm -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -exception-model=seh -include-pch C:/Users/Richard/Project/RepoTest/clang-bug-pch-and-module/build/CMakeFiles/main.dir/cmake_pch.hxx.pch -include C:/Users/Richard/Project/RepoTest/clang-bug-pch-and-module/build/CMakeFiles/main.dir/cmake_pch.hxx -faddrsig -o CMakeFiles/main.dir/src/module2/module.cppm.obj -x pcm CMakeFiles/main.dir/module2.pcm
Exception Code: 0xC0000005
#0 0x00007ff9741ed676 clang::ASTReader::getLocalModuleFile(clang::serialization::ModuleFile&, unsigned int) const (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x205d676)
#1 0x00007ff97425fb90 clang::serialization::MultiOnDiskHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::add(clang::serialization::ModuleFile*, unsigned char const*, clang::serialization::reader::ASTDeclContextNameLookupTrait) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x20cfb90)
#2 0x00007ff97425eb5e clang::ASTReader::loadDeclUpdateRecords(clang::ASTReader::PendingUpdateRecord&) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x20ceb5e)
#3 0x00007ff974219143 clang::ASTReader::finishPendingActions() (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x2089143)
#4 0x00007ff97421c7a6 clang::ASTReader::FinishedDeserializing() (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x208c7a6)
#5 0x00007ff974202671 clang::ASTReader::ReadAST(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, clang::serialization::ModuleFile**) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x2072671)
#6 0x00007ff974358526 clang::ASTUnit::LoadFromASTFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, clang::PCHContainerReader const&, clang::ASTUnit::WhatToLoad, llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>, clang::FileSystemOptions const&, std::__1::shared_ptr<clang::HeaderSearchOptions>, std::__1::shared_ptr<clang::LangOptions>, bool, clang::CaptureDiagsKind, bool, bool, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x21c8526)
#7 0x00007ff972a3118a clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x8a118a)
#8 0x00007ff972a2a250 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x89a250)
#9 0x00007ff972a29b92 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (C:\dev\msys2\clang64\bin\libclang-cpp.dll+0x899b92)
#10 0x00007ff671dc4c75 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (C:\dev\msys2\clang64\bin\clang++.exe+0x4c75)
#11 0x00007ff671dc44a6 llvm::raw_ostream::operator<<(llvm::StringRef) (C:\dev\msys2\clang64\bin\clang++.exe+0x44a6)
#12 0x00007ff671dc144c clang_main(int, char**, llvm::ToolContext const&) (C:\dev\msys2\clang64\bin\clang++.exe+0x144c)
#13 0x00007ff671dc1075 main (C:\dev\msys2\clang64\bin\clang++.exe+0x1075)
#14 0x00007ff671dcb44c WinMainCRTStartup (C:\dev\msys2\clang64\bin\clang++.exe+0xb44c)
#15 0x00007ff671dcb4a6 mainCRTStartup (C:\dev\msys2\clang64\bin\clang++.exe+0xb4a6)
#16 0x00007ff9d8aae8d7 (C:\WINDOWS\System32\KERNEL32.DLL+0x2e8d7)
#17 0x00007ff9daa5fbcc (C:\WINDOWS\SYSTEM32\ntdll.dll+0xdfbcc)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.1.7
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/dev/msys2/clang64/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: C:/Users/Richard/AppData/Local/Temp/module-fe3c7d.cppm
clang++: note: diagnostic msg: C:/Users/Richard/AppData/Local/Temp/module-fe3c7d.sh
clang++: note: diagnostic msg:
********************
ninja: build stopped: subcommand failed.