<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121259>121259</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang crashes when using pre-compiled headers and modules at the same time.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          YiRanMushroom
      </td>
    </tr>
</table>

<pre>
    I was trying to compile my project using modules and PCMs simultaneously. At first, it was okay, but later, when I used too many modules in a source file, clang crashed, here is the log:
```
FAILED: CMakeFiles/sdl2_games.dir/src/application/application.cppm.obj CMakeFiles/sdl2_games.dir/application.pcm 
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE  -IE:/code/C++/sdl2_games/src/headers -isystem E:/code/C++/sdl2_games/cmake-build-debug/vcpkg_installed/x64-windows-static/include -isystem E:/code/C++/sdl2_games/cmake-build-debug/vcpkg_installed/x64-windows-static/include/SDL2 -O0 -std=gnu++23 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -Xclang -include-pch -Xclang E:/code/C++/sdl2_games/cmake-build-debug/CMakeFiles/sdl2_games.dir/cmake_pch.hxx.pch -Xclang -include -Xclang E:/code/C++/sdl2_games/cmake-build-debug/CMakeFiles/sdl2_games.dir/cmake_pch.hxx -MD -MT CMakeFiles/sdl2_games.dir/src/application/application.cppm.obj -MF CMakeFiles\sdl2_games.dir\src\application\application.cppm.obj.d @CMakeFiles\sdl2_games.dir\src\application\application.cppm.obj.modmap -o CMakeFiles/sdl2_games.dir/src/application/application.cppm.obj -c E:/code/C++/sdl2_games/src/application/application.cppm
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:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.41.34123 -emit-obj -mincremental-linker-compatible -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name application.cppm -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -gno-column-info -gcodeview -debug-info-kind=constructor -fdebug-compilation-dir=E:\\code\\C++\\sdl2_games\\cmake-build-debug -object-file-name=E:\\code\\C++\\sdl2_games\\cmake-build-debug\\CMakeFiles\\sdl2_games.dir\\src\\application\\application.cppm.obj -fcoverage-compilation-dir=E:\\code\\C++\\sdl2_games\\cmake-build-debug -resource-dir "C:\\Program Files\\LLVM\\lib\\clang\\19" -O0 -std=gnu++23 -fdeprecated-macro -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.41.34123 -fno-implicit-modules -fmodule-file=template_string=CMakeFiles/sdl2_games.dir/template_string.pcm -fmodule-file=SDL2_EventListener=CMakeFiles/sdl2_games.dir/SDL2_EventListener.pcm -fmodule-file=newModule=CMakeFiles/sdl2_games.dir/newModule.pcm -fmodule-file=SDL2_ImGui_VM=CMakeFiles/sdl2_games.dir/SDL2_ImGui_VM.pcm -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions --dependent-lib=msvcrtd -gcodeview -include-pch E:/code/C++/sdl2_games/cmake-build-debug/CMakeFiles/sdl2_games.dir/cmake_pch.hxx.pch -include E:/code/C++/sdl2_games/cmake-build-debug/CMakeFiles/sdl2_games.dir/cmake_pch.hxx -faddrsig -o CMakeFiles/sdl2_games.dir/src/application/application.cppm.obj -x pcm CMakeFiles/sdl2_games.dir/application.pcm
Exception Code: 0xC0000005
 #0 0x00007ff65a7ad706 (C:\Program Files\LLVM\bin\clang++.exe+0x23cd706)
 #1 0x00007ff65b3d59e5 (C:\Program Files\LLVM\bin\clang++.exe+0x2ff59e5)
 #2 0x00007ff65b3d47eb (C:\Program Files\LLVM\bin\clang++.exe+0x2ff47eb)
 #3 0x00007ff65a7d8e33 (C:\Program Files\LLVM\bin\clang++.exe+0x23f8e33)
 #4 0x00007ff65a7dc0b7 (C:\Program Files\LLVM\bin\clang++.exe+0x23fc0b7)
 #5 0x00007ff65a7c4bf1 (C:\Program Files\LLVM\bin\clang++.exe+0x23e4bf1)
 #6 0x00007ff65b4506e7 (C:\Program Files\LLVM\bin\clang++.exe+0x30706e7)
 #7 0x00007ff6589b87fb (C:\Program Files\LLVM\bin\clang++.exe+0x5d87fb)
 #8 0x00007ff6589a3703 (C:\Program Files\LLVM\bin\clang++.exe+0x5c3703)
 #9 0x00007ff6589a0486 (C:\Program Files\LLVM\bin\clang++.exe+0x5c0486)
#10 0x00007ff65899d445 (C:\Program Files\LLVM\bin\clang++.exe+0x5bd445)
#11 0x00007ff65899bdde (C:\Program Files\LLVM\bin\clang++.exe+0x5bbdde)
#12 0x00007ff65882348a (C:\Program Files\LLVM\bin\clang++.exe+0x44348a)
#13 0x00007ff65881fee3 (C:\Program Files\LLVM\bin\clang++.exe+0x43fee3)
#14 0x00007ff659fe2d58 (C:\Program Files\LLVM\bin\clang++.exe+0x1c02d58)
#15 0x00007ff9f8bc259d (C:\windows\System32\KERNEL32.DLL+0x1259d)
#16 0x00007ff9f91caf38 (C:\windows\SYSTEM32\ntdll.dll+0x5af38)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.1.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\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\Yiran\AppData\Local\Temp\application-28b6b0.cppm
clang++: note: diagnostic msg: C:\Users\Yiran\AppData\Local\Temp\application-28b6b0.sh
clang++: note: diagnostic msg: 

********************
ninja: build stopped: subcommand failed.
```

Compiling this file is not easy since other files are needed. However, reproducing the issue is not hard.
[application-28b6b0.sh.txt](https://github.com/user-attachments/files/18265761/application-28b6b0.sh.txt)
[application-28b6b0.cppm.txt](https://github.com/user-attachments/files/18265760/application-28b6b0.cppm.txt)

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8WUtz46gW_jXK5hQqPR17kYXbj57Udaa7ujNzZ1YpBEcyEwQqQI6zmd9-C-RnOv2YcW6nXBWB4PvgvDgHUWtFoxBvovJdVM6vaO_W2tz8KT5RddfbtdG6vao0f765hSdqwZlnoRpwGphuOyER2mfojP4LmYPe-net5r1EC1Rx-Di7s2BF20tHFereyucYpg5qYayLshkIF2D1I332zap3IKlD4xtPa1RwC71FDk5raKl6PqALBRSs7g1DqIVEP4FJqhpghto1ct-xRoMgLLg1gtRNlE-jZBqNkt0vmS6nt6vFPMqnMLujj7gUEm2ULS2X2UNDW7QxF8Z3GBZlS9p1UjDqhFbnrZh1XRvr6q_vwJxO6VgLUTKd-UWVs4-fPrz_NP07jcrZavX7XVTOKqGicjZbTX99__B3Gi_-WACQ24Ufni2Z5hhly1mUvQu_E6rDatdIORoLRNhn67CFH5rLWvqIpOqF5IRj1TdRttyw7rF5EMo6KqWX7HI7KsiTUFw_WWIddcITCsVkz_GnE0bZ8vN8lQH5kACxjkf5vFH9wJblQOYP88W7396Hh9XK_7u7B_LHYC2EcOxQcVSOSFFF-by1G2YcB9IcBzV-DxuBT8euHTnp2PrQ-a83_G2zCTMeOraO19ttfEpIDjL_iSsAcjcHcnf_Vj5D7panUOXsBVQ581Dl7BTqrHWAijlERfJGWK3mLe2A6DfbJ_sx9fwIYJRMP64W088LsH3VCgcUqr4Bg502zofntXOdHdiibNkIt-6rmOk2ypZSbvb_yC50e2eytg_0IXDv7cpHzhBQoaLs0RnKQqTtDHZGM7Q-Ng9R2Hf7mdRazQR1yMH0CiwzonNxlEw_O8oegfdtN8ThJI6SyUejG0NboKbpW1TOLxmiLNuFRR8ZdyP2Cj1GyEOQjMpZsP5BnDFuMcoyIIyl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