<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63306>63306</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`clangtk`: Assertion `NumBits <= MAX_INT_BITS && "bitwidth too large"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wierton
</td>
</tr>
</table>
<pre>
When compile below program using `clangtk` with option `-O1`, `clangtk` crashes:
```
typedef struct { signed char m; } _t;
typedef struct { _t m[4]; } a_t;
typedef struct { a_t m[4]; } b_t;
typedef struct { b_t m[4]; } c_t;
typedef struct { c_t m[4]; } d_t;
typedef struct { d_t m[4]; } e_t;
typedef struct { e_t m[4]; } f_t;
typedef struct { f_t m[4]; } g_t;
typedef struct { g_t m[4]; } h_t;
typedef struct { h_t m[4]; } i_t;
typedef struct { i_t m[4]; } j_t;
void f(j_t *r, a_t *r1) {
_t r0 = {1};
b_t r2;
c_t r3;
d_t r4;
e_t r5;
f_t r6;
g_t r7;
h_t r8;
i_t r9;
r1->m[0] = r0; r1->m[1] = r0; r1->m[2] = r0; r1->m[3] = r0;
r2.m[0] = *r1; r2.m[1] = *r1; r2.m[2] = *r1; r2.m[3] = *r1;
r3.m[0] = r2; r3.m[1] = r2; r3.m[2] = r2; r3.m[3] = r2;
r4.m[0] = r3; r4.m[1] = r3; r4.m[2] = r3; r4.m[3] = r3;
r5.m[0] = r4; r5.m[1] = r4; r5.m[2] = r4; r5.m[3] = r4;
r6.m[0] = r5; r6.m[1] = r5; r6.m[2] = r5; r6.m[3] = r5;
r7.m[0] = r6; r7.m[1] = r6; r7.m[2] = r6; r7.m[3] = r6;
r8.m[0] = r7; r8.m[1] = r7; r8.m[2] = r7; r8.m[3] = r7;
r9.m[0] = r8; r9.m[1] = r8; r9.m[2] = r8; r9.m[3] = r8;
r->m[0] = r9; r->m[1] = r9; r->m[2] = r9; r->m[3] = r9;
}
```
the outputs of compilation command:
```
$ time clang-17 -O1 small.c
clang-17: /home/xfou/llvm-project-trunk/llvm/lib/IR/Type.cpp:341: static llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int): Assertion `NumBits <= MAX_INT_BITS && "bitwidth too large"' 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: /home/xfou/disk/llvm-project-trunk.obj.release+assertion/bin/clang-17 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/xfou/bugs/24 -resource-dir /home/xfou/disk/llvm-project-trunk.obj.release+assertion/lib/clang/17 -internal-isystem /home/xfou/disk/llvm-project-trunk.obj.release+assertion/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -fdebug-compilation-dir=/home/xfou/bugs/24 -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-c1af2c.o -x c small.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'small.c'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVMSupport.so.17git 0x00007fe6eedc90df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63
1 libLLVMSupport.so.17git 0x00007fe6eedc66ce
2 libc.so.6 0x00007fe6ee7f3520
3 libc.so.6 0x00007fe6ee847a7c pthread_kill + 300
4 libc.so.6 0x00007fe6ee7f3476 raise + 22
5 libc.so.6 0x00007fe6ee7d97f3 abort + 211
6 libc.so.6 0x00007fe6ee7d971b
7 libc.so.6 0x00007fe6ee7eae96
8 libLLVMCore.so.17git 0x00007fe6ef8a3528 llvm::IntegerType::get(llvm::LLVMContext&, unsigned int) + 808
9 libLLVMCodeGen.so.17git 0x00007fe6f24936ed llvm::EVT::getExtendedIntegerVT(llvm::LLVMContext&, unsigned int) + 13
10 libLLVMSelectionDAG.so.17git 0x00007fe6ee023201
11 libLLVMSelectionDAG.so.17git 0x00007fe6ee09a1cb
12 libLLVMSelectionDAG.so.17git 0x00007fe6ee09f7b5
13 libLLVMSelectionDAG.so.17git 0x00007fe6ee0a15cb llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) + 3355
14 libLLVMSelectionDAG.so.17git 0x00007fe6ee2cbdd8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 792
15 libLLVMSelectionDAG.so.17git 0x00007fe6ee2cf608 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 2920
16 libLLVMSelectionDAG.so.17git 0x00007fe6ee2d14c7
17 libLLVMX86CodeGen.so.17git 0x00007fe6f464c2b0
18 libLLVMCodeGen.so.17git 0x00007fe6f212f962
19 libLLVMCore.so.17git 0x00007fe6ef830b64 llvm::FPPassManager::runOnFunction(llvm::Function&) + 868
20 libLLVMCore.so.17git 0x00007fe6ef830db9 llvm::FPPassManager::runOnModule(llvm::Module&) + 57
21 libLLVMCore.so.17git 0x00007fe6ef831645 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 901
22 libclangCodeGen.so.17git 0x00007fe6f28bcf3a clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) + 6250
23 libclangCodeGen.so.17git 0x00007fe6f2d3b4e5
24 libclangParse.so.17git 0x00007fe6ec11bba9 clang::ParseAST(clang::Sema&, bool, bool) + 1145
25 libclangFrontend.so.17git 0x00007fe6f154f249 clang::FrontendAction::Execute() + 201
26 libclangFrontend.so.17git 0x00007fe6f14c5806 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 342
27 libclangFrontendTool.so.17git 0x00007fe6f3f4a08c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 460
28 clang-17 0x00005651f90fa5c5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2549
29 clang-17 0x00005651f90f6293
30 clang-17 0x00005651f90f793e clang_main(int, char**, llvm::ToolContext const&) + 5374
31 clang-17 0x00005651f90f09e3 main + 51
32 libc.so.6 0x00007fe6ee7dad90
33 libc.so.6 0x00007fe6ee7dae40 __libc_start_main + 128
34 clang-17 0x00005651f90f0a25 _start + 37
clang-17: error: unable to execute command: Aborted
clang-17: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.0 (wierton@114.212.81.121:~/llvm-project-trunk ff75a2be34fd76350216c36b7ea4c3f338df6215)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-17: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-17: note: diagnostic msg: /tmp/small-c6e757.c
clang-17: note: diagnostic msg: /tmp/small-c6e757.sh
clang-17: note: diagnostic msg:
********************
clang-17 -O1 small.c 23.11s user 0.51s system 99% cpu 23.625 total
```
As shown in the output log, the compilation takes up to 23 seconds to complete. Therefore, gcc.godbolt.org cannot reproduce the crash due to its time limit restriction. The following output log is taken from gcc.godbolt.org and can be viewed at https://gcc.godbolt.org/z/G6Mnn3b6W:
```
Killed - processing time exceeded
Compiler returned: 143
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Wl9T67iS_zTmpcspW_K_PPAQCDlD7TkX6sDOzO5LSpbbjubYUlaSgXMf9rNvSXYSJyTMcHcuRUFo9a-73ep_lmDGiEYiXgfpTZAur1hvN0pfvwrUVsmrUlU_r3_boASuuq1oEUps1StstWo066A3QjYQZBFvmWzsjyCL4FXYDaitFUq6lfAhDrIoILcnbFwzs0ET0EUQLYNo4ZiGb_-n_bnFCmswVvfcQpDfgLe0Ar5hGrqA3kCQL2FtA3pzEbK20AXpTRKkyx2AfYxgZyDlx5DyDIR_DOFnINXHkOoMBD-G4BlI_TGkPgNpPoY0ZyCbjyGbMxDxMUScgfwxgQw_X5SooA5I8cfaQkAW2sUdGz_HAZk7WQMruODQEQR06YhxkC_3wsDvqSYTgtsxTScEtx86mRCct3U6IThf6mxCcJ7S-YTg_KCLCcE9pZ6fPBSAjsOA3rnHj4J06U3WkfPCYSG-tEAuLdCjhVGVJrMjNYPfHG5YiC8tkEsL9HRh_1D0WJV3944an6WSs1R6RN2LT07EUw9JTsRPqeQslR5R9-LTE_GJh6Qn4qdUcpZKj6h78dmJ-NRDshPxUyo5S6VH1L34_ER85iH5ifgplZyl0iPqXnxxIj73kOJE_JRKzlLpEXUvfn4ivvCQ-Yn4KZWcpdIj6l78-2Sbe9D7XDumkwt0ekQfUztfnu17YwHcIKjebntrQNVj82W-pXLVdUxWl_pmQBKwokPwrTaMcwgfYjAda9sZH1h2KwFdQEBWG9VhQFZvteoDsmrbly7cavUHchta3csfI9H9EmVAVvffA7J6_rnFGd9uA7qgSewkGcus4OBZ6SKgi3tpsUHtOAOyuLDgCQ3agBQHhq9ff_12q6TFNxuQzJXwXo7NX0gbkLnTtzAG9W7I-Eff3QhrIKC3zs_fFr-v7__xvL65f34CLyKDgJBS2FdR2Q1YpaBlusGAkIDkUDPRY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