Discussion:
[ast-developers] Hint from $ clang -fsanitize=address ... # why "nmake" sometimes goes boom (because of |strcpy()| overlap) ...
Roland Mainz
2013-08-11 02:49:11 UTC
Permalink
Hi!

----

An attempt to build ast-open.2013-08-07 on SuSE 12.3/AMD64/64bit with
"clang"'s address sanitiser came back with a hint why "nnake"
sometimes goes "boom" or somehow generates corrupted data:
-- snip --
$ (export CC='/usr/bin/clang -std=gnu1x -fsanitize=address -g
-fno-omit-frame-pointer -fno-optimize-sibling-calls -Wno-parentheses
-Wno-logical-op-parentheses -Wno-unused' LD="$CC" CCFLAGS="-g"; ksh
./bin/package make PACKAGE_OPTIONS='map-libc' CC="$CC"
CCFLAGS="$CCFLAGS" 2>&1 | tee -a buildlog.log)
[snip]
package: believe generated files for nmake
CC=cc
SHELL=/usr/bin/ksh
HOSTTYPE=linux.i386-64
NPROC=2
PACKAGEROOT=/home/test001/work/ast_ksh_20130807/build_clang
INSTALLROOT=/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64
PATH=/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin:/home/test001/work/ast_ksh_20130807/build_clang/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/test001/bin:/u
sr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin
probing C language processor
/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/cc
for make information
cmd/INIT:
=================================================================
==50399==ERROR: AddressSanitizer: strcpy-param-overlap: memory ranges
[0x7f796eb74eb0,0x7f796eb74ece) and [0x7f796eb74eb0, 0x7f796eb74ece)
overlap
#0 0x41e4aa
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x41e4aa)
#1 0x6e4352
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x6e4352)
#2 0x6e13fc
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x6e13fc)
#3 0x614a13
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x614a13)
#4 0x5f19ed
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x5f19ed)
#5 0x46e48d
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x46e48d)
#6 0x601323
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x601323)
#7 0x5f1905
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x5f1905)
#8 0x648dd0
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x648dd0)
#9 0x63f322
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x63f322)
#10 0x5343a9
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x5343a9)
#11 0x7f796de3fa14 (/lib64/libc-2.17.so+0x21a14)
#12 0x42e94c
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x42e94c)
==50399==ABORTING
make: *** exit code 1 making cmd/INIT
-- snip --
... this happens because |strcpy()| is called with overlapping memory
areas (which isn't valid in ISO C because the results are undefined).
I don't have a better stack trace yet... I still have to figure out
how to get to that with "clang"'s address santitiser

-----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Glenn Fowler
2013-08-12 15:47:14 UTC
Permalink
Post by Roland Mainz
Hi!
----
An attempt to build ast-open.2013-08-07 on SuSE 12.3/AMD64/64bit with
"clang"'s address sanitiser came back with a hint why "nnake"
-- snip --
$ (export CC='/usr/bin/clang -std=gnu1x -fsanitize=address -g
-fno-omit-frame-pointer -fno-optimize-sibling-calls -Wno-parentheses
-Wno-logical-op-parentheses -Wno-unused' LD="$CC" CCFLAGS="-g"; ksh
./bin/package make PACKAGE_OPTIONS='map-libc' CC="$CC"
CCFLAGS="$CCFLAGS" 2>&1 | tee -a buildlog.log)
[snip]
package: believe generated files for nmake
CC=cc
SHELL=/usr/bin/ksh
HOSTTYPE=linux.i386-64
NPROC=2
PACKAGEROOT=/home/test001/work/ast_ksh_20130807/build_clang
INSTALLROOT=/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64
PATH=/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin:/home/test001/work/ast_ksh_20130807/build_clang/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/test001/bin:/u
sr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin
probing C language processor
/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/cc
for make information
=================================================================
==50399==ERROR: AddressSanitizer: strcpy-param-overlap: memory ranges
[0x7f796eb74eb0,0x7f796eb74ece) and [0x7f796eb74eb0, 0x7f796eb74ece)
overlap
#0 0x41e4aa
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x41e4aa)
#1 0x6e4352
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x6e4352)
#2 0x6e13fc
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x6e13fc)
#3 0x614a13
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x614a13)
#4 0x5f19ed
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x5f19ed)
#5 0x46e48d
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x46e48d)
#6 0x601323
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x601323)
#7 0x5f1905
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x5f1905)
#8 0x648dd0
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x648dd0)
#9 0x63f322
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x63f322)
#10 0x5343a9
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x5343a9)
#11 0x7f796de3fa14 (/lib64/libc-2.17.so+0x21a14)
#12 0x42e94c
(/home/test001/work/ast_ksh_20130807/build_clang/arch/linux.i386-64/bin/nmake+0x42e94c)
==50399==ABORTING
make: *** exit code 1 making cmd/INIT
-- snip --
... this happens because |strcpy()| is called with overlapping memory
areas (which isn't valid in ISO C because the results are undefined).
I don't have a better stack trace yet... I still have to figure out
how to get to that with "clang"'s address santitiser
this would be good to nail down
earlier this year we went through sfio and cleaned up a few of these
Loading...