<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117713>117713</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
SIGSEGV on x86-64 platform with clang-trunk when compiling the program with very-large function parameter without optimization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wangbo15
</td>
</tr>
</table>
<pre>
On the `x86-64` platform, the following code gets a `SIGSEGV` when compiled with `clang-trunk` without any option.
However, if optimization is enabled (e.g., `-O1`, the program executes and exits normally.
The same code compiles and runs correctly with GCC without any optimization flags. Interestingly, if the size of `a5` is reduced from `38000` to `37000`, the program occasionally runs successfully with clang-trunk.
Here is the minimal reproducer, also in gotblot: https://godbolt.org/z/jz4hj9Pco
```cpp
class type_2 {
int a1[252525];
int a2[252525];
int a3[252525];
int a4[252525];
int a5[38000]; // if change to a5[37000], the program can randomly pass.
} object;
void test(type_2) {}
int main() {
test(object);
}
```
The `ulimit` of my computer is as follows, where the stack size is `8M`, larger than the `object` (which is about `4.19 MB`) :
```
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 642079
max locked memory (kbytes, -l) 65536
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 642079
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0Vs1u27wSfRp6M7BBUZYsL7xwmuu2i6IFenFxdx8oaiyxoUiVpOw4T_9hJPknCuIEMOw5M3PO0ZBjGYKuLeKOZU8se17IPjbO787S1qVLskXpqsvup4XYILCcvxb5Ml-znENnZDw63zLxZQgenTHurG0NylU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