Bug#832627: clang-3.6: Crash on fabs(undeclared_indentifier)

Ben Wiederhake BenWiederhake.GitHub at gmx.de
Wed Jul 27 19:54:57 UTC 2016


Package: clang-3.6
Version: 1:3.6.2-3
Severity: normal

Dear Maintainer,

the following highly minimal code causes clang to crash:

#include <math.h> /* fabs */
int main() {  fabs(undeclared_variable);  }

Compile with:
clang -c -o /dev/null crasher.c

Expected behavior:
Print an error about the undeclared variable 'undeclared_variable',
or something like that.  (gcc does this.)

Actual behavior:
clang segfaults.

Please find attached the requested files:
- stacktrace (crasher-log.txt)
- preprocessed source (crasher-916dfe.c)
- run script (crasher-916dfe.sh)
For each of the following platforms:
- i686
- x68-64

The crash is 100% reproducible with clang-3.6,
Apparently, this bug has been fixed in clang-3.7 and clang-3.8,
but as the package 'clang' still only depends on clang-3.6,
a backport of the patch (or something) would be nice.

Thanks for maintaining clang :)

Regards,
Ben Wiederhake



-- System Information:
Debian Release: stretch/sid
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages clang-3.6 depends on:
ii  binutils                 2.26.1-1
ii  libc6                    2.23-2
ii  libc6-dev                2.23-2
ii  libclang-common-3.6-dev  1:3.6.2-3
ii  libclang1-3.6            1:3.6.2-3
ii  libedit2                 3.1-20150325-1+b1
ii  libffi6                  3.2.1-4
ii  libgcc-5-dev             5.4.0-6
ii  libgcc1                  1:6.1.1-9
ii  libllvm3.6v5             1:3.6.2-3
ii  libobjc-5-dev            5.4.0-6
ii  libstdc++-5-dev          5.4.0-6
ii  libstdc++6               6.1.1-9
ii  libtinfo5                6.0+20160625-1
ii  zlib1g                   1:1.2.8.dfsg-2+b1

Versions of packages clang-3.6 recommends:
pn  llvm-3.6-dev  <none>
ii  python        2.7.11-2

Versions of packages clang-3.6 suggests:
pn  clang-3.6-doc  <none>
pn  gnustep        <none>
pn  gnustep-devel  <none>

-- no debconf information
-------------- next part --------------
$ clang -c -o /dev/null crasher.c
0  libLLVM-3.6.so.1 0xb62386f7 llvm::sys::PrintStackTrace(_IO_FILE*) + 39
1  libLLVM-3.6.so.1 0xb623891c
2  libLLVM-3.6.so.1 0xb6236e70
3  linux-gate.so.1  0xb777ed90 __kernel_sigreturn + 0
4  linux-gate.so.1  0xbfc0c63c __kernel_sigreturn + 138991788
Stack dump:
0.	Program arguments: /usr/lib/llvm-3.6/bin/clang -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name crasher.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4 -target-linker-version 2.25.1 -dwarf-column-info -coverage-file /dev/null -resource-dir /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2/include -internal-externc-isystem /usr/include/i386-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/user/<SNIP>/clang-crash -ferror-limit 19 -fmessage-length 101 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /dev/null -x c crasher.c
1.	crasher.c:8:29: current parser token ')'
2.	crasher.c:7:12: parsing function body 'main'
3.	crasher.c:7:12: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Debian clang version 3.6.2-3 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: i386-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://bugs.debian.org/ and include the crash backtrace, preprocessed source, and associated run script.
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: /tmp/crasher-916dfe.c
clang: note: diagnostic msg: /tmp/crasher-916dfe.sh
clang: note: diagnostic msg:

********************
-------------- next part --------------
$ clang -c -o /dev/null crasher.c
0  libLLVM-3.6.so.1 0x00007f853f0ccf72 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1  libLLVM-3.6.so.1 0x00007f853f0cb779
2  libpthread.so.0  0x00007f853dd72ed0
3  libpthread.so.0  0x0000000002953330
Stack dump:
0.	Program arguments: /usr/lib/llvm-3.6/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name crasher.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.25.1 -dwarf-column-info -coverage-file /dev/null -resource-dir /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/eispin/Dropbox/uni/unofficial/clang-crash -ferror-limit 19 -fmessage-length 126 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /dev/null -x c crasher.c 
1.	crasher.c:8:29: current parser token ')'
2.	crasher.c:7:12: parsing function body 'main'
3.	crasher.c:7:12: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Debian clang version 3.6.2-3 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://bugs.debian.org/ and include the crash backtrace, preprocessed source, and associated run script.
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: /tmp/crasher-614bea.c
clang: note: diagnostic msg: /tmp/crasher-614bea.sh
clang: note: diagnostic msg: 

********************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crasher_preprocessed_i686.c
Type: text/x-c
Size: 120716 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20160727/21dfa4e9/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crasher_preprocessed_x86-64.c
Type: text/x-c
Size: 121262 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20160727/21dfa4e9/attachment-0003.bin>
-------------- next part --------------
 "/usr/lib/llvm-3.6/bin/clang" "-cc1" "-triple" "i386-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "crasher.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-fuse-init-array" "-target-cpu" "pentium4" "-target-linker-version" "2.25.1" "-dwarf-column-info" "-ferror-limit" "19" "-fmessage-length" "101" "-mstackrealign" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c" "crasher-916dfe.c"
-------------- next part --------------
 "/usr/lib/llvm-3.6/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "crasher.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-target-linker-version" "2.25.1" "-dwarf-column-info" "-ferror-limit" "19" "-fmessage-length" "126" "-mstackrealign" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c" "crasher-614bea.c"


More information about the Pkg-llvm-team mailing list