llvm / llvm/llvm-project

Clang 22.1.7 crashes during C++23 module compilation (internal compiler error)

Open
#204,110 0 comments 0 reactions 0 assignees View on GitHub
crash llvm:codegen
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Title:
Clang 22.1.7 crashes during C++23 module compilation (internal compiler error)

Description:
Clang crashes when compiling a C++23 module in an MSYS2 UCRT64 environment. The error is reproducible. The error occurs when attempting to include a class file with the () operator with a large number of specializations.

Environment:

clang++ 22.1.7

Target: x86_64-w64-windows-gnu

MSYS2 UCRT64

Windows 10/11

Command line:
```
C:\msys64\ucrt64\bin\clang++.exe -DFMT_SHARED -DFile_EXPORTS -D_WIN32 -D_WINDOWS -ID:/Luna/root/file/include -ID:/Luna/root/external/fmt/include -ID:/Luna/root/common/include -stdlib=libc++ -ggdb -std=gnu++23 -fms-extensions -Winvalid-specialization -MD -MT root/file/CMakeFiles/File.dir/module/serialize/json.cppm.obj -MF root\file\CMakeFiles\File.dir\module\serialize\json.cppm.obj.d @root\file\CMakeFiles\File.dir\module\serialize\json.cppm.obj.modmap -o root/file/CMakeFiles/File.dir/module/serialize/json.cppm.obj -c D:/Luna/root/file/module/serialize/json.cppm
Stack trace:
Stack dump:
0. Program arguments: C:\\msys64\\ucrt64\\bin\\clang++.exe -DFMT_SHARED -DFile_EXPORTS -D_WIN32 -D_WINDOWS -ID:/Luna/root/file/include -ID:/Luna/root/external/fmt/include -ID:/Luna/root/common/include -stdlib=libc++ -ggdb -std=gnu++23 -fms-extensions -Winvalid-specialization -MD -MT root/file/CMakeFiles/File.dir/module/serialize/json.cppm.obj -MF root\\file\\CMakeFiles\\File.dir\\module\\serialize\\json.cppm.obj.d @root\\file\\CMakeFiles\\File.dir\\module\\serialize\\json.cppm.obj.modmap -o root/file/CMakeFiles/File.dir/module/serialize/json.cppm.obj -c D:/Luna/root/file/module/serialize/json.cppm
1. parser at end of file
2. Code generation
Exception Code: 0xC0000005
0x00007FFB68B8FA80, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x40BFA80 byte(s), _ZNK4llvm7Mangler17getNameWithPrefixERNS_11raw_ostreamEPKNS_11GlobalValueEb() + 0xA0 byte(s)
0x00007FFB68B8FDC7, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x40BFDC7 byte(s), _ZNK4llvm7Mangler17getNameWithPrefixERNS_15SmallVectorImplIcEEPKNS_11GlobalValueEb() + 0x87 byte(s)
0x00007FFB6804AE5B, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x357AE5B byte(s), _ZNK4llvm13TargetMachine9getSymbolEPKNS_11GlobalValueE() + 0xAB byte(s)
0x00007FFB65F4272E, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x147272E byte(s), _ZN4llvm10AsmPrinter18emitXXStructorListERKNS_10DataLayoutEPKNS_8ConstantEb() + 0x18E byte(s)
0x00007FFB65F4599B, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x147599B byte(s), _ZN4llvm10AsmPrinter21emitSpecialLLVMGlobalEPKNS_14GlobalVariableE() + 0x54B byte(s)
0x00007FFB65F418F3, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x14718F3 byte(s), _ZN4llvm10AsmPrinter18emitGlobalVariableEPKNS_14GlobalVariableE() + 0xB3 byte(s)
0x00007FFB65F374D0, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x14674D0 byte(s), _ZN4llvm10AsmPrinter14doFinalizationERNS_6ModuleE() + 0x500 byte(s)
0x00007FFB66623B71, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x1B53B71 byte(s), _ZN4llvm13FPPassManager14doFinalizationERNS_6ModuleE() + 0x31 byte(s)
0x00007FFB67962282, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x2E92282 byte(s), _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE() + 0x1292 byte(s)
0x00007FFB98EC2D45, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x10F2D45 byte(s), _ZN5clang17emitBackendOutputERNS_16CompilerInstanceERNS_14CodeGenOptionsEN4llvm9StringRefEPNS4_6ModuleENS_13BackendActionENS4_18IntrusiveRefCntPtrINS4_3vfs10FileSystemEEESt10unique_ptrINS4_17raw_pwrite_streamESt14default_deleteISE_EEPNS_15BackendConsumerE() + 0x10E5 byte(s)
0x00007FFB98DAA7A1, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0xFDA7A1 byte(s), _ZN5clang15BackendConsumer21HandleTranslationUnitERNS_10ASTContextE() + 0x7D1 byte(s)
0x00007FFB98EAD7FC, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x10DD7FC byte(s), _ZN5clang17MultiplexConsumer21HandleTranslationUnitERNS_10ASTContextE() + 0x2C byte(s)
0x00007FFB99F4E9D7, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x217E9D7 byte(s), _ZN5clang8ParseASTERNS_4SemaEbb() + 0x287 byte(s)
0x00007FFB98CE1FBF, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0xF11FBF byte(s), _ZN5clang14FrontendAction7ExecuteEv() + 0x2F byte(s)
0x00007FFB98E665E4, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x10965E4 byte(s), _ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE() + 0x434 byte(s)
0x00007FFB9944F29D, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x167F29D byte(s), _ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE() + 0x30D byte(s)
0x00007FF73C94ECB3, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0xECB3 byte(s)
0x00007FF73C94F11D, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0xF11D byte(s)
0x00007FF73C94F910, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0xF910 byte(s)
0x00007FFB98588EED, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x7B8EED byte(s), _ZN4llvm12append_rangeISt6vectorIPKN5clang7VarDeclESaIS5_EERNS_12ImmutableSetIS5_NS_17ImutContainerInfoIS5_EEEEEEvRT_OT0_() + 0x24DBD byte(s)
0x00007FFB67081739, C:\msys64\ucrt64\bin\libLLVM-22.dll(0x00007FFB64AD0000) + 0x25B1739 byte(s), _ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE() + 0x89 byte(s)
0x00007FFB9A401E72, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x2631E72 byte(s), _ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefISt8optionalINS2_9StringRefEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb() + 0x192 byte(s)
0x00007FFB9A445944, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x2675944 byte(s), _ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_b() + 0x354 byte(s)
0x00007FFB9A44541C, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x267541C byte(s), _ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEEb() + 0x8C byte(s)
0x00007FFB999FC129, C:\msys64\ucrt64\bin\libclang-cpp.dll(0x00007FFB97DD0000) + 0x1C2C129 byte(s), _ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE() + 0x169 byte(s)
0x00007FF73C94A8B1, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0xA8B1 byte(s)
0x00007FF73C954E6F, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0x14E6F byte(s)
0x00007FF73C9410DA, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0x10DA byte(s)
0x00007FF73C941456, C:\msys64\ucrt64\bin\clang++.exe(0x00007FF73C940000) + 0x1456 byte(s)
0x00007FFBE4BF7374, C:\WINDOWS\System32\KERNEL32.DLL(0x00007FFBE4BE0000) + 0x17374 byte(s), BaseThreadInitThunk() + 0x14 byte(s)
0x00007FFBE587CC91, C:\WINDOWS\SYSTEM32\ntdll.dll(0x00007FFBE5830000) + 0x4CC91 byte(s), RtlUserThreadStart() + 0x21 byte(s)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 22.1.7 (https://github.com/msys2/MINGW-packages b8f306ad57e0c8f3f15aed0dc809d7e3e8e2eee9)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/ucrt64/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/szef/AppData/Local/Temp/json-e9c0a2.cppm
clang++: note: diagnostic msg: C:/Users/szef/AppData/Local/Temp/json-e9c0a2.sh
clang++: note: diagnostic msg:

********************
```
Preprocessed source:

[json-e9c0a2.txt](https://github.com/user-attachments/files/28997299/json-e9c0a2.txt)
Run script:
[json-e9c0a2.sh](https://github.com/user-attachments/files/28997242/json-e9c0a2.sh)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached json-e9c0a2.sh script with json-e9c0a2.cppm using Clang 22.1.7 in the stated MSYS2 UCRT64 environment. Inspect the code-generation stack around Mangler and AsmPrinter, then confirm the reproducer no longer causes an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.