[Bug]Trying to add Asan support to arm android gcc4.9 toolchain, got some error,plz help!

262 views
Skip to first unread message

ji wang

unread,
Jul 16, 2014, 5:13:19 AM7/16/14
to address-...@googlegroups.com
Hi,
Since GCC4.9 got ARM support for Asan already, so I try to build a new 4.9 version of arm android toolchain with asan enabled those days. Now toolchain have been compiled successfully, but after I build a UseAfterFree testcase binary with -fsanitize=address and run, I got a SEGV_MAPERR abort error in logcat. Any ideas what could be wrong? Or any mannul for what I do now?
Host:x86_64-linux-gnu ubuntu 12.04, Build:x86_64-linux-gnu ubuntu 12.04, Target: android 4.4  phone devices
Here is my steps I've done: 
1. Download android toolchain source code from googlesource.com
2. Build arm gcc android toolchain with asan enabled:
./arm-linux-androideabi-gcc -v
Using built-in specs.
COLLECT_GCC=./arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=/home/star/codes/android-toolchain-src/prefix/libexec/gcc/arm-linux-androideabi/4.9/lto-wrapper
Target: arm-linux-androideabi
Configured with: .././../gcc/gcc-4.9/configure --prefix=/home/star/codes/android-toolchain-src/prefix --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/home/start/codes/android-toolchain-src/prefix --with-mpfr=/home/star/codes/android-toolchain-src/prefix --with-mpc=/home/star/codes/android-toolchain-src/prefix --without-ppl --without-cloog --without-isl --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --enable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-gcc-version=4.9 --with-binutils-version=2.21 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-mpfr-version=3.1.1 --with-gdb-version=7.3.x --with-arch=armv5te --with-sysroot=/home/star/codes/android-toolchain-src/build/sysroot --with-gold-version=2.21 --enable-gold --with-cloog-version=0.17.0 --with-ppl-version=1.0 --prefix=/home/star/codes/android-toolchain-src/prefix --enable-libsanitizer --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default
Thread model: posix
gcc version 4.9 20140514 (prerelease) (GCC)
3. Testcase UseAfterFree make
LOCAL_CFLAGS += -fsanitize=address
LOCAL_LDFLAGS += -fsanitize=address -lasan -lstdc++  -lsupc++  -lgcc -ldl
4. Run this UseAfterFree testcase binary in devices, got SIGV abort:
08-16 08:59:26.255: I/DEBUG(2385): pid: 5926, tid: 5926, name: asan_use_after_  >>> asan_use_after_free <<<
08-16 08:59:26.255: I/DEBUG(2385): AM write failure (32 / Broken pipe)
08-16 08:59:26.255: I/DEBUG(2385): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
08-16 08:59:26.255: W/NativeCrashListener(2862): Couldn't find ProcessRecord for pid 5926
08-16 08:59:26.260: I/DEBUG(2385):     r0 0000000b  r1 beb587b8  r2 00000000  r3 00000000
08-16 08:59:26.260: I/DEBUG(2385):     r4 0000000b  r5 beb587b8  r6 04000000  r7 b6fc1108
08-16 08:59:26.260: I/DEBUG(2385):     r8 0000000a  r9 b6f5f678  sl 00000001  fp b6fbd07c
08-16 08:59:26.260: I/DEBUG(2385):     ip 00000000  sp beb587a8  lr b6f9b7bc  pc 00000000  cpsr 600e0010
08-16 08:59:26.260: I/DEBUG(2385):     d0  402551033b141503  d1  7972617262696c20
08-16 08:59:26.260: I/DEBUG(2385):     d2  0000000000000069  d3  0000000000000073
08-16 08:59:26.260: I/DEBUG(2385):     d4  0000000000000000  d5  0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d6  0000000000000000  d7  4016314000000000
08-16 08:59:26.260: I/DEBUG(2385):     d8  0000000000000000  d9  0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d10 0000000000000000  d11 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d12 0000000000000000  d13 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d14 0000000000000000  d15 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d16 41d0095440f5f3b6  d17 3f50624dd2f1a9fc
08-16 08:59:26.260: I/DEBUG(2385):     d18 41cd8a0a81800000  d19 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d20 0000000000000000  d21 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d22 0000000000000000  d23 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d24 0000000000000000  d25 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d26 0000000000000000  d27 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d28 0000000000000000  d29 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     d30 0000000000000000  d31 0000000000000000
08-16 08:59:26.260: I/DEBUG(2385):     scr 00000010
08-16 08:59:26.265: I/DEBUG(2385): backtrace:
08-16 08:59:26.265: I/DEBUG(2385):     #00  pc 00000000  <unknown>
08-16 08:59:26.265: I/DEBUG(2385):     #01  pc 0003a7b8  /system/bin/asan_use_after_free       ------->>>>>>gcc-4.9/libsanitizer/asan/asan_posix.cc:44>>>>>CHECK_EQ(0, REAL(sigaction)(signum, &sigact, 0));
08-16 08:59:26.265: I/DEBUG(2385):     #02  pc 0003a9f0  /system/bin/asan_use_after_free        ------->>>>>>gcc-4.9/libsanitizer/asan/asan_posix.cc:37>>>>>if (!AsanInterceptsSignal(signum))
08-16 08:59:26.265: I/DEBUG(2385):     #03  pc 0002c3d8  /system/bin/asan_use_after_free        ------->>>>>>gcc/gcc-4.9/libsanitizer/asan/asan_rtl.cc:526>>>>  InstallSignalHandlers();
08-16 08:59:26.265: I/DEBUG(2385):     #04  pc 00005025  /system/bin/asan_use_after_free
08-16 08:59:26.265: I/DEBUG(2385):     #05  pc 0000272d  /system/bin/linker
08-16 08:59:26.265: I/DEBUG(2385):     #06  pc 00002803  /system/bin/linker
08-16 08:59:26.265: I/DEBUG(2385):     #07  pc 00002955  /system/bin/linker
08-16 08:59:26.265: I/DEBUG(2385):     #08  pc 00003003  /system/bin/linker
08-16 08:59:26.265: I/DEBUG(2385):     #09  pc 00000a68  /system/bin/linker
08-16 08:59:26.265: I/DEBUG(2385): stack:
08-16 08:59:26.265: I/DEBUG(2385):          beb58768  00000000 
08-16 08:59:26.265: I/DEBUG(2385):          beb5876c  1fffffff 
08-16 08:59:26.265: I/DEBUG(2385):          beb58770  b6ead000 
08-16 08:59:26.265: I/DEBUG(2385):          beb58774  00002000 
08-16 08:59:26.265: I/DEBUG(2385):          beb58778  beb587ac  [stack]
08-16 08:59:26.265: I/DEBUG(2385):          beb5877c  b6eab000 
08-16 08:59:26.265: I/DEBUG(2385):          beb58780  beb587b0  [stack]
08-16 08:59:26.265: I/DEBUG(2385):          beb58784  beb587b0  [stack]
08-16 08:59:26.265: I/DEBUG(2385):          beb58788  00000000 
08-16 08:59:26.265: I/DEBUG(2385):          beb5878c  b6f9307c  /system/bin/asan_use_after_free
08-16 08:59:26.265: I/DEBUG(2385):          beb58790  00000001 
08-16 08:59:26.265: I/DEBUG(2385):          beb58794  b6f90ce8  /system/bin/asan_use_after_free
08-16 08:59:26.265: I/DEBUG(2385):          beb58798  b74163ac 
08-16 08:59:26.265: I/DEBUG(2385):          beb5879c  b6f9bb74  /system/bin/asan_use_after_free
08-16 08:59:26.265: I/DEBUG(2385):          beb587a0  b74163ac 
08-16 08:59:26.265: I/DEBUG(2385):          beb587a4  beb587b8  [stack]
08-16 08:59:26.265: I/DEBUG(2385):     #00  beb587a8  00000000 
08-16 08:59:26.265: I/DEBUG(2385):          ........  ........
08-16 08:59:26.265: I/DEBUG(2385):     #01  beb587a8  00000000 
08-16 08:59:26.265: I/DEBUG(2385):          beb587ac  b6efc838  /system/lib/libc.so (pthread_key_create+212)
08-16 08:59:26.265: I/DEBUG(2385):          beb587b0  00000001 
08-16 08:59:26.265: I/DEBUG(2385):          beb587b4  b6fbdef0  /system/bin/asan_use_after_free
08-16 08:59:26.265: I/DEBUG(2385):          beb587b8  b6f9b6f4  /system/bin/asan_use_after_free
08-16 08:59:26.265: I/DEBUG(2385):          beb587bc  00000000 
08-16 08:59:26.265: I/DEBUG(2385):          beb587c0  00000004 
08-16 08:59:26.270: I/DEBUG(2385):          beb587c4  00000000 
08-16 08:59:26.270: I/DEBUG(2385):          beb587c8  b6f9bb74  /system/bin/asan_use_after_free
08-16 08:59:26.270: I/DEBUG(2385):          beb587cc  b6fbdef0  /system/bin/asan_use_after_free
08-16 08:59:26.270: I/DEBUG(2385):          beb587d0  1c000000 
08-16 08:59:26.270: I/DEBUG(2385):          beb587d4  b6f9b9f4  /system/bin/asan_use_after_free
08-16 08:59:26.270: I/DEBUG(2385):     #02  beb587d8  00000000 
08-16 08:59:26.270: I/DEBUG(2385):          beb587dc  b6f8d3dc  /system/bin/asan_use_after_free
08-16 08:59:26.270: I/DEBUG(2385): memory near r1:
08-16 08:59:26.270: I/DEBUG(2385):     beb58798 b74163ac b6f9bb74 b74163ac beb587b8 
08-16 08:59:26.270: I/DEBUG(2385):     beb587a8 00000000 b6efc838 00000001 b6fbdef0 
08-16 08:59:26.270: I/DEBUG(2385):     beb587b8 b6f9b6f4 00000000 00000004 00000000 
08-16 08:59:26.270: I/DEBUG(2385):     beb587c8 b6f9bb74 b6fbdef0 1c000000 b6f9b9f4 
08-16 08:59:26.270: I/DEBUG(2385):     beb587d8 00000000 b6f8d3dc b6f1474d b6f14753 
08-16 08:59:26.270: I/DEBUG(2385):     beb587e8 b6f1474f b6f5072f b6f4b128 b6f5af04 
08-16 08:59:26.270: I/DEBUG(2385):     beb587f8 00000000 b6f66021 b6f5af04 b6f4b004 
08-16 08:59:26.270: I/DEBUG(2385):     beb58808 b6f5afc7 b6f66029 b6f66023 b6f5072f 
08-16 08:59:26.270: I/DEBUG(2385):     beb58818 b6f4b004 b6f5af04 00000001 00000000 
08-16 08:59:26.270: I/DEBUG(2385):     beb58828 b6f4b004 b6f50807 b6eeafa0 b6ed2f05 
08-16 08:59:26.270: I/DEBUG(2385):     beb58838 b6f5f678 b6f5a409 b6f5af77 00000004 
08-16 08:59:26.270: I/DEBUG(2385):     beb58848 b6f5a409 b6f5af04 b6f5f0a8 b6f4b004 
08-16 08:59:26.270: I/DEBUG(2385):     beb58858 b6fbd314 b6f62aca b6f5f678 b6f5a409 
08-16 08:59:26.270: I/DEBUG(2385):     beb58868 b6f5af77 b6f5f1d0 b6f5f670 b6f50959 
08-16 08:59:26.270: I/DEBUG(2385):     beb58878 00000000 b6f5fccc b6f61000 b6f5fccc 
08-16 08:59:26.270: I/DEBUG(2385):     beb58888 b6f4b004 b6f5f680 00000000 00000000 
08-16 08:59:26.270: I/DEBUG(2385): memory near r5:
08-16 08:59:26.270: I/DEBUG(2385):     beb58798 b74163ac b6f9bb74 b74163ac beb587b8 
08-16 08:59:26.270: I/DEBUG(2385):     beb587a8 00000000 b6efc838 00000001 b6fbdef0 
08-16 08:59:26.270: I/DEBUG(2385):     beb587b8 b6f9b6f4 00000000 00000004 00000000 
08-16 08:59:26.270: I/DEBUG(2385):     beb587c8 b6f9bb74 b6fbdef0 1c000000 b6f9b9f4 
08-16 08:59:26.270: I/DEBUG(2385):     beb587d8 00000000 b6f8d3dc b6f1474d b6f14753 
08-16 08:59:26.270: I/DEBUG(2385):     beb587e8 b6f1474f b6f5072f b6f4b128 b6f5af04 
08-16 08:59:26.270: I/DEBUG(2385):     beb587f8 00000000 b6f66021 b6f5af04 b6f4b004 
08-16 08:59:26.270: I/DEBUG(2385):     beb58808 b6f5afc7 b6f66029 b6f66023 b6f5072f 
08-16 08:59:26.270: I/DEBUG(2385):     beb58818 b6f4b004 b6f5af04 00000001 00000000 
08-16 08:59:26.270: I/DEBUG(2385):     beb58828 b6f4b004 b6f50807 b6eeafa0 b6ed2f05 
08-16 08:59:26.270: I/DEBUG(2385):     beb58838 b6f5f678 b6f5a409 b6f5af77 00000004 
08-16 08:59:26.270: I/DEBUG(2385):     beb58848 b6f5a409 b6f5af04 b6f5f0a8 b6f4b004 
08-16 08:59:26.270: I/DEBUG(2385):     beb58858 b6fbd314 b6f62aca b6f5f678 b6f5a409 
08-16 08:59:26.270: I/DEBUG(2385):     beb58868 b6f5af77 b6f5f1d0 b6f5f670 b6f50959 
08-16 08:59:26.270: I/DEBUG(2385):     beb58878 00000000 b6f5fccc b6f61000 b6f5fccc 
08-16 08:59:26.270: I/DEBUG(2385):     beb58888 b6f4b004 b6f5f680 00000000 00000000 
08-16 08:59:26.270: I/DEBUG(2385): memory near r6:
08-16 08:59:26.270: I/DEBUG(2385):     03ffffe0 00000000 00000000 00000000 00000000 
08-16 08:59:26.270: I/DEBUG(2385):     03fffff0 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000000 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000010 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000020 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000030 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000040 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000050 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000060 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000070 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000080 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     04000090 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     040000a0 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     040000b0 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     040000c0 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     040000d0 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385): memory near r7:
08-16 08:59:26.275: I/DEBUG(2385):     b6fc10e8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc10f8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1108 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1118 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1128 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1138 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1148 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1158 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1168 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1178 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1188 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc1198 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc11a8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc11b8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc11c8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fc11d8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385): memory near r9:
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f658 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f668 00000000 00000000 b6f4b474 b6f4b004 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f678 00000000 b6f4b000 7379732f 2f6d6574 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f688 2f6e6962 6b6e696c 00007265 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f698 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f6a8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f6b8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f6c8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f6d8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f6e8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f6f8 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f708 00000000 b6f4e000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f718 b6f5eed4 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f728 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f738 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6f5f748 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385): memory near fp:
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd05c 00000006 00000001 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd06c 00000000 00000000 ffffffff 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd07c b6f66021 ffffffff b6f67004 b6f8ddb0 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd08c b6f8e964 b6f9a580 b6fa6e1c b6fa79c4 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd09c b6fa7d3c 00000000 b6f66009 ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd0ac 00000000 00000000 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd0bc 00000000 b6f87d8c b6f87c5c b6f87eb8 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd0cc b6f88054 b6f88188 00000000 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd0dc 00000000 b6fbd138 b6fb746a 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd0ec b6fbd108 b6f8e924 b6f8e928 b6f8dde0 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd0fc b6f8e92c b6f8ddec b6f8e930 b6fbd200 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd10c b6fb7494 b6fbd0e0 00000000 b6fbd138 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd11c b6fb74ba b6fbd200 b6fb750e b6fbd118 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd12c 00000000 00000000 b6fbd160 b6fa68e4 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd13c b6fa690c b6fa7b84 b6fa7b84 b6fa6954 
08-16 08:59:26.275: I/DEBUG(2385):     b6fbd14c b6fa6874 b6fa6928 b6fa6998 b6fa68d0 
08-16 08:59:26.275: I/DEBUG(2385): memory near sp:
08-16 08:59:26.275: I/DEBUG(2385):     beb58788 00000000 b6f9307c 00000001 b6f90ce8 
08-16 08:59:26.275: I/DEBUG(2385):     beb58798 b74163ac b6f9bb74 b74163ac beb587b8 
08-16 08:59:26.275: I/DEBUG(2385):     beb587a8 00000000 b6efc838 00000001 b6fbdef0 
08-16 08:59:26.275: I/DEBUG(2385):     beb587b8 b6f9b6f4 00000000 00000004 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     beb587c8 b6f9bb74 b6fbdef0 1c000000 b6f9b9f4 
08-16 08:59:26.275: I/DEBUG(2385):     beb587d8 00000000 b6f8d3dc b6f1474d b6f14753 
08-16 08:59:26.275: I/DEBUG(2385):     beb587e8 b6f1474f b6f5072f b6f4b128 b6f5af04 
08-16 08:59:26.275: I/DEBUG(2385):     beb587f8 00000000 b6f66021 b6f5af04 b6f4b004 
08-16 08:59:26.275: I/DEBUG(2385):     beb58808 b6f5afc7 b6f66029 b6f66023 b6f5072f 
08-16 08:59:26.275: I/DEBUG(2385):     beb58818 b6f4b004 b6f5af04 00000001 00000000 
08-16 08:59:26.275: I/DEBUG(2385):     beb58828 b6f4b004 b6f50807 b6eeafa0 b6ed2f05 
08-16 08:59:26.275: I/DEBUG(2385):     beb58838 b6f5f678 b6f5a409 b6f5af77 00000004 
08-16 08:59:26.275: I/DEBUG(2385):     beb58848 b6f5a409 b6f5af04 b6f5f0a8 b6f4b004 
08-16 08:59:26.275: I/DEBUG(2385):     beb58858 b6fbd314 b6f62aca b6f5f678 b6f5a409 
08-16 08:59:26.275: I/DEBUG(2385):     beb58868 b6f5af77 b6f5f1d0 b6f5f670 b6f50959 
08-16 08:59:26.275: I/DEBUG(2385):     beb58878 00000000 b6f5fccc b6f61000 b6f5fccc 
08-16 08:59:26.275: I/DEBUG(2385): code around pc:
08-16 08:59:26.275: I/DEBUG(2385):     00000000 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000010 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000020 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000030 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000040 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000050 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000060 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000070 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000080 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     00000090 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     000000a0 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     000000b0 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     000000c0 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     000000d0 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     000000e0 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385):     000000f0 ffffffff ffffffff ffffffff ffffffff 
08-16 08:59:26.275: I/DEBUG(2385): code around lr:
08-16 08:59:26.275: I/DEBUG(2385):     b6f9b79c e5d33032 e3530000 159f307c 158d3018 
08-16 08:59:26.275: I/DEBUG(2385):     b6f9b7ac e59f3078 e79f3003 e5933000 e12fff33 
08-16 08:59:26.275: I/DEBUG(2385):     b6f9b7bc e1a01fc0 e1903001 0a000009 e3a02000 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b7cc e3a03000 e1cd00f8 e1cd20f0 e59f0050 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b7dc e59f2050 e08f0000 e3a0102c e08f2002 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b7ec ebffe3c4 e59f3040 e08f3003 e5933018 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b7fc e3530000 da000003 e59f0030 e1a01004 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b80c e08f0000 ebffebb3 e28dd024 e8bd8030 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b81c 00021c18 ffffff70 00021bc4 08000004 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b82c 000226c8 0001ab13 0001ab48 00024898 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b83c 0001ab64 e92d4030 e24dd02c e3a00000 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b84c e28d1010 ebff2925 e1a04000 e1a05fc0 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b85c e1943005 0a000009 e3a02000 e3a03000 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b86c e1cd20f0 e59f00b4 e59f20b4 e1cd40f8 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b87c e08f0000 e3a0103d e08f2002 ea000017 
08-16 08:59:26.280: I/DEBUG(2385):     b6f9b88c e59d3014 e3130002 0a000022 e59f1094 
08-16 08:59:26.300: I/BootReceiver(2862): Copying /data/tombstones/tombstone_08 to DropBox (SYSTEM_TOMBSTONE)
 
 
 

 
 

Evgeniy Stepanov

unread,
Jul 17, 2014, 7:56:50 AM7/17/14
to address-...@googlegroups.com
You are linking asan runtime library into the executable. That's not
how clang does it, and it would not work on Android because of runtime
loader quirks.

https://code.google.com/p/address-sanitizer/wiki/Android
> --
> You received this message because you are subscribed to the Google Groups
> "address-sanitizer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to address-saniti...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

ji wang

unread,
Jul 17, 2014, 9:48:32 PM7/17/14
to address-...@googlegroups.com
Hi, Evgeniy
First of all, What I do now is porting asan to android  gcc toolchain, not using Clang.
And secondly, about the Clang using,  I think we have to link the asan runtime libray into the executable, witch means we must add  LOCAL_ADDRESS_SANITIZER:=true to the Android.mk of the executable, otherwise we will get nothing no error detected. And the defination of LOCAL_ADDRESS_SANITIZER have links to the libasan_preload.so and libasan.a. And in this Gcc using, without -lasan part, we will get compile error that some asan funtions undined.
So, am I think it the right way?  Have you guys tried the GCC Asan using? Thanks.

在 2014年7月17日星期四UTC+8下午7时56分50秒,Evgeniy Stepanov写道:

Evgeniy Stepanov

unread,
Jul 23, 2014, 7:03:02 AM7/23/14
to address-...@googlegroups.com
Hi,

sorry for the delayed answer.

libasan.a is linked statically to the executable. libasan_preload.so
is linked _dynamically_ to both executable and libraries, and at
runtime is injected with LD_PRELOAD setting in asanwrapper.

From your logs code that should normally be in libasan_preload.so got
linked statically into the executable, see frames 1-3. It looks like a
difference between clang and gcc drivers, where gcc defaults to static
linking of asan runtime.

ji wang

unread,
Jul 23, 2014, 10:29:16 PM7/23/14
to address-...@googlegroups.com
Hi,Evgeniy
   Thanks for your reply. And after thsoe days works, I've got Asan enabled arm-linux-androideabi-4.9 toochain working now, well,
to be more precisely maybe partially works well.
   The error above gone now, after
I disabled ASAN_NEEDS_SEGV macro, because in android platform, asan don't have its own SEGV signal handler implemention.
   And further after some other bugs fixed, I can use this customized toolchain to check some excutable binaries
and got exact errors detected(some mem error were planted in those excutable), like the mediaserver now.  But the new problem is that I still can't use it for some libraries like libhwui.so. I reboot the android devices,
when the
instrumented libhwui.so loading, I got some errors as follow, Why we got those error? Have any ideas for this?  Anything helpful will be great.
08-23 10:22:13.384: I/mediaserver(12679): ==12680==Using the defaults from __asan_default_options:
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'strcmp'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'strncmp'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'strcasecmp'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'strncasecmp'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'read'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'pread'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'readv'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'write'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'pwrite'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'writev'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'prctl'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'localtime'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'localtime_r'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'gmtime'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'gmtime_r'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'ctime'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'ctime_r'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'asctime'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'asctime_r'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'strptime'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'scanf'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'sscanf'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'fscanf'
08-23 10:22:13.384: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'vscanf'
   ...
... ...
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'longjmp'
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept '_longjmp'
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'siglongjmp'
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept 'pthread_create'
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer: failed to intercept '__cxa_atexit'
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer: libc interceptors initialized
08-23 10:22:13.404: I/mediaserver(12679): || `[0x20000000, 0xffffffff]` || HighMem    ||
08-23 10:22:13.404: I/mediaserver(12679): || `[0x04000000, 0x1fffffff]` || HighShadow ||
08-23 10:22:13.404: I/mediaserver(12679): || `[0x00040000, 0x03ffffff]` || ShadowGap  ||
08-23 10:22:13.404: I/mediaserver(12679): MemToShadow(shadow): 0x00000000 0x00000000 0x00800000 0x03ffffff
08-23 10:22:13.404: I/mediaserver(12679): red_zone=16
08-23 10:22:13.404: I/mediaserver(12679): quarantine_size=64M
08-23 10:22:13.404: I/mediaserver(12679): malloc_context_size=30
08-23 10:22:13.404: I/mediaserver(12679): SHADOW_SCALE: 3
08-23 10:22:13.404: I/mediaserver(12679): SHADOW_GRANULARITY: 8
08-23 10:22:13.404: I/mediaserver(12679): SHADOW_OFFSET: 0
08-23 10:22:13.404: I/mediaserver(12679): ==12680==AddressSanitizer CHECK failed: ../../../.././../gcc/gcc-4.9/libsanitizer/asan/asan_poisoning.cc:25 "((__interception::real_memset)) != (0)" (0x0, 0x0)
08-23 10:22:13.404: I/mediaserver(12679):     <empty stack>
08-23 10:22:13.404: I/mediaserver(12679): mediaserver terminated by exit(1)

Besides, GCC only have libasan.a one static lib, don't have any other links when we use this toolchain.
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9$ find . -name libasan*
./arm-linux-androideabi/lib/libasan.a
./arm-linux-androideabi/lib/armv7-a/libasan.a
./arm-linux-androideabi/lib/armv7-a/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/hard/libasan.a
./arm-linux-androideabi/lib/armv7-a/hard/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/hard/libasan.la
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.a
./arm-linux-androideabi/lib/armv7-a/thumb/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.a
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.la
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.la
./arm-linux-androideabi/lib/armv7-a/libasan.la
./arm-linux-androideabi/lib/libasan_preinit.o
./arm-linux-androideabi/lib/thumb/libasan.a
./arm-linux-androideabi/lib/thumb/libasan_preinit.o
./arm-linux-androideabi/lib/thumb/libasan.la
./arm-linux-androideabi/lib/libasan.la



在 2014年7月23日星期三UTC+8下午7时03分02秒,Evgeniy Stepanov写道:

Evgeniy Stepanov

unread,
Jul 24, 2014, 3:29:05 AM7/24/14
to address-...@googlegroups.com
I'm not familiar with gcc build system, but it looks like this
toolchain has only static asan runtime. This would not work on
Android.

Error looks a bit strange though. Is it possible that you link static
asan runtime into the binary, and then LD_PRELOAD a shared runtime?

ji wang

unread,
Jul 24, 2014, 11:19:32 PM7/24/14
to address-...@googlegroups.com
Yes, this toolchain I made only have static asan runtime, Why this would not work on android? we have to use a shared asan runtime?
I found a wiki page about the problem what I am dealing with(FYI: android platform):
https://code.google.com/p/address-sanitizer/wiki/AsanAsDso
  • There is third-party executable binary which can not be recompiled
  • It loads shared libraries that can be recompiled and we want to test them with ASAN
And I don't want use LD_PRELOAD things, so I try to build GCC asan myself, but only got static asan runtime in my toolchain.


在 2014年7月24日星期四UTC+8下午3时29分05秒,Evgeniy Stepanov写道:

ji wang

unread,
Jul 25, 2014, 4:42:56 AM7/25/14
to address-...@googlegroups.com
And I recompiled my toolchain, and got the shared asan runtime: which CFlags or LDFlags I should pass to Android.mk?


prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9$ find . -name libasan*
./arm-linux-androideabi/lib/libasan.so.1.0.0
./arm-linux-androideabi/lib/libasan.a
./arm-linux-androideabi/lib/armv7-a/libasan.so.1.0.0
./arm-linux-androideabi/lib/armv7-a/libasan.a
./arm-linux-androideabi/lib/armv7-a/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/hard/libasan.so.1.0.0
./arm-linux-androideabi/lib/armv7-a/hard/libasan.a
./arm-linux-androideabi/lib/armv7-a/hard/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/hard/libasan.so
./arm-linux-androideabi/lib/armv7-a/hard/libasan.la
./arm-linux-androideabi/lib/armv7-a/hard/libasan.so.1
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.so.1.0.0
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.a
./arm-linux-androideabi/lib/armv7-a/thumb/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.so.1.0.0
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.a
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan_preinit.o
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.so
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.la
./arm-linux-androideabi/lib/armv7-a/thumb/hard/libasan.so.1
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.so
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.la
./arm-linux-androideabi/lib/armv7-a/thumb/libasan.so.1
./arm-linux-androideabi/lib/armv7-a/libasan.so
./arm-linux-androideabi/lib/armv7-a/libasan.la
./arm-linux-androideabi/lib/armv7-a/libasan.so.1
./arm-linux-androideabi/lib/libasan_preinit.o
./arm-linux-androideabi/lib/thumb/libasan.so.1.0.0
./arm-linux-androideabi/lib/thumb/libasan.a
./arm-linux-androideabi/lib/thumb/libasan_preinit.o
./arm-linux-androideabi/lib/thumb/libasan.so
./arm-linux-androideabi/lib/thumb/libasan.la
./arm-linux-androideabi/lib/thumb/libasan.so.1
./arm-linux-androideabi/lib/libasan.so
./arm-linux-androideabi/lib/libasan.la
./arm-linux-androideabi/lib/libasan.so.1


在 2014年7月25日星期五UTC+8上午11时19分32秒,ji wang写道:
Reply all
Reply to author
Forward
0 new messages