<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Crash on extremely long string"
href="https://bugs.llvm.org/show_bug.cgi?id=42301">42301</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash on extremely long string
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>taolzu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22114" name="attach_22114" title="Contains hello-943593.c and hello-943593.sh">attachment 22114</a> <a href="attachment.cgi?id=22114&action=edit" title="Contains hello-943593.c and hello-943593.sh">[details]</a></span>
Contains hello-943593.c and hello-943593.sh
I tried to compile this generated code in gcc and clang:
```bash
#!/bin/sh
printf '#include <stdio.h>\nchar s[] = "' > hello.c
python -c 'print("h" * 4294967296)' >> hello.c
truncate -s -1 hello.c
printf '";' >> hello.c
cat >> hello.c << EOF
int main()
{
printf("%s\n", s);
return 0;
}
EOF
gcc hello.c -o hello_gcc
clang hello.c -o hello_clang # crash
```
With gcc:
```bash
% gdb hello_gcc
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb) disas main
Dump of assembler code for function main:
0x0000000000001130 <+0>: push rbp
0x0000000000001131 <+1>: mov rbp,rsp
0x0000000000001134 <+4>: lea rdi,[rip+0x2ec6] # 0x4001 <s>
0x000000000000113b <+11>: call 0x1210 <puts@plt>
0x0000000000001140 <+16>: mov eax,0x0
0x0000000000001145 <+21>: pop rbp
0x0000000000001146 <+22>: ret
End of assembler dump.
(gdb) x/s 0x4001
0x4001 <s>: ""
(gdb) quit
```
With clang:
```bash
% clang hello.c
Stack dump:
0. Program arguments: /home/lzutao/.local/bin/clang-8 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name hello.c
-mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmat
h-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir
/home/lzutao/.local/lib/clang/8.0.0 -internal-isystem /usr/local/include
-internal-isystem /home/lzutao/.local/lib/clang/
8.0.0/include -internal-externc-isystem /home/lzutao/.local/include
-internal-externc-isystem /usr/lib/gcc/x86_64-linux-gnu/6/include-fixed
-internal-externc-isystem /usr/include -internal-externc-isystem
/usr/local/include -internal-externc-isystem /usr/include/x86_64-l
inux-gnu -fdebug-compilation-dir /home/lzutao/forked/rust/check -ferror-limit
19 -fmessage-length 135 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/hello-27434e.o -x c hello.c -faddrsig
1. clang-8: error: unable to execute command: Alarm clock
clang-8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 8.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lzutao/.local/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-8: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/hello-943593.c
clang-8: note: diagnostic msg: /tmp/hello-943593.sh
clang-8: note: diagnostic msg:
********************
```
### Meta
```bash
% clang --version
clang version 8.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lzutao/.local/bin
% gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>