[llvm-bugs] [Bug 42301] New: Crash on extremely long string

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 17 12:11:35 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42301

            Bug ID: 42301
           Summary: Crash on extremely long string
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: taolzu at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 22114
  --> https://bugs.llvm.org/attachment.cgi?id=22114&action=edit
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 at 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
https://bugs.llvm.org/ 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.
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190617/f8c47d57/attachment.html>


More information about the llvm-bugs mailing list