This is an archive of the discontinued LLVM Phabricator instance.

Reland [lsan] Enable LSAN for Android
ClosedPublic

Authored by oontvoo on Oct 12 2020, 9:39 AM.

Details

Summary

Reland: a2291a58bf1c860d026581fee6fe96019dc25440.

New fixes for the breakages reported in D85927 include:

  • declare a weak decl for dl_iterate_phdr, because it does not exist on older APIs
  • Do not enable leak-sanitizer if api_level is less than 29, because of ld.lld: error: undefined symbol: __aeabi_read_tp for armv7, API level 16.
  • Put back the interceptor for memalign but still opt out intercepting __libc_memalign and cfree because both of these don't exist in Bionic.

Diff Detail

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
srhines requested changes to this revision.Oct 12 2020, 9:42 AM
srhines added a subscriber: srhines.
srhines added inline comments.
compiler-rt/lib/lsan/lsan_common.h
31

I really think this should be 30, and that local testing should patch over this. Otherwise, this will likely cause conflicts when Android does toolchain releases in AOSP, as people will get different behavior when they set 29.

This revision now requires changes to proceed.Oct 12 2020, 9:42 AM

This looks wrong. Api level has nothing to do with compile-time support for TLS, and thread-properties API is used with runtime detection (through a weak symbol).

oontvoo marked an inline comment as done.Oct 12 2020, 11:49 AM

This looks wrong. Api level has nothing to do with compile-time support for TLS, and thread-properties API is used with runtime detection (through a weak symbol).

K, wrong explanation. Code is right-ish, though. :-)
Updated the comment.

compiler-rt/lib/lsan/lsan_common.h
31

Done. Thanks!

oontvoo updated this revision to Diff 297653.Oct 12 2020, 11:49 AM
oontvoo marked an inline comment as done.

updated diff

srhines added inline comments.Oct 12 2020, 12:09 PM
compiler-rt/lib/lsan/lsan_common.h
28

I feel like I'm still missing something here. The comment above says to change it to 31 when that is available. Making this a number where it doesn't work will break our NDK release process until 31 is available (next year). I'm not ok with that. If you have features that you're testing for the future, that testing should be the one reverting/modifying patches, not the NDK itself (which is what I would likely have to do if I accept this patch based on the explanation in the comment).

eugenis added inline comments.Oct 12 2020, 12:21 PM
compiler-rt/lib/lsan/lsan_common.h
28

Still don't understand why this is a compile time requirement.
Thread properties API has runtime detection!

compiler-rt/lib/lsan/lsan_interceptors.cpp
115 ↗(On Diff #297653)

I still don't get this. Android libc has memalign. You can not replace some allocation functions but not the others - imagine what will happen when this memory is deallocated later with lsan's free().

Why does asan work with a memalign interceptor?
Do you have a stack trace of the failure?

oontvoo added inline comments.Oct 12 2020, 12:31 PM
compiler-rt/lib/lsan/lsan_common.h
28

Still don't understand why this is a compile time requirement.
Thread properties API has runtime detection!

The compile time requirement here is not for the thread-properties API. It is for dl_iterate_phdr.
dmajor@ reported that in their build, they are getting a compilation error because dl_iterate_phdr is missing in API 16.

We could say, the minimum requirement is is API 16 to avoid the error but there is no point in doing that because even though lsan could compile for android-api-level 16, it will not run.

28

I feel like I'm still missing something here. The comment above says to change it to 31 when that is available. Making this a number where it doesn't work will break our NDK release process until 31 is available (next year). I'm not ok with that. If you have features that you're testing for the future, that testing should be the one reverting/modifying patches, not the NDK itself (which is what I would likely have to do if I accept this patch based on the explanation in the comment).

The v2 patch still fails with

[task 2020-10-12T19:34:27.889Z] /builds/worker/fetches/llvm-project/llvm/runtimes/compiler-rt/lib/lsan/lsan_common_linux.cpp:126:3: error: use of undeclared identifier 'dl_iterate_phdr'
[task 2020-10-12T19:34:27.889Z]   dl_iterate_phdr(ProcessGlobalRegionsCallback, frontier);
[task 2020-10-12T19:34:27.889Z]   ^
[task 2020-10-12T19:34:27.889Z] /builds/worker/fetches/llvm-project/llvm/runtimes/compiler-rt/lib/lsan/lsan_common_linux.cpp:167:3: error: use of undeclared identifier 'dl_iterate_phdr'
[task 2020-10-12T19:34:27.889Z]   dl_iterate_phdr(LockStuffAndStopTheWorldCallback, &param);
[task 2020-10-12T19:34:27.889Z]   ^

Do you have a way to test an API 16 build locally, for faster iteration? Sending patches to our bots is slow because the bots only know how to do a clean build, and there are several points in the pipeline where tasks get delayed due to machine pool capacity.

eugenis added inline comments.Oct 12 2020, 12:37 PM
compiler-rt/lib/lsan/lsan_common.h
28

Just make it weak :)
There is a precedent in sanitizer_common/sanitizer_linux.cpp.

Without this, the NDK will get LSan only when the base api level is updated to 31, which is basically never. Unless NDK ships multiple version of the asan runtime library, one per level.

oontvoo added inline comments.Oct 12 2020, 12:38 PM
compiler-rt/lib/lsan/lsan_common.h
28

srhines ^ : (sorry, the comment got left behind)

It will not break because there is runtime check to decide whether LSAN will be enabled. This API-level compile check is only there to prevent build breakages on older android where dl_iterate_phdr is not present.

oontvoo updated this revision to Diff 297686.Oct 12 2020, 1:45 PM
oontvoo marked an inline comment as done.

Move weak decl to header so that it'll be available to users.

> 
> Do you have a way to test an API 16 build locally, for faster iteration? Sending patches to our bots is slow because the bots only know how to do a clean build, and there are several points in the pipeline where tasks get delayed due to machine pool capacity.

Sorry, the minimum I could get is 21 for an x86 emulator and ~27 for a real aarch64 test device. 
But making this a weak, as eugenis suggested, *should* work. PTAL.
compiler-rt/lib/lsan/lsan_common.h
28

Why does the weak decl in sanitizer_common/sanitizer_linux.cpp not make it into here?
Should that be moved to some shared header?

compiler-rt/lib/lsan/lsan_interceptors.cpp
115 ↗(On Diff #297653)

I still don't get this. Android libc has memalign. You can not replace some allocation functions but not the others - imagine what will happen when this memory is deallocated later with lsan's free().

That's why I'd opted out intercepting cfree() too

Why does asan work with a memalign interceptor?

Not sure why asan init did not involve memalign

Do you have a stack trace of the failure?

Breakpoint 1, memalign () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/lsan/lsan_interceptors.cpp:99
99	  ENSURE_LSAN_INITED;
(gdb) bt
#0  memalign () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/lsan/lsan_interceptors.cpp:99
#1  0xf76e7793 in ?? ()
#2  0xf76e4e09 in ?? ()
#3  0xf7706407 in ?? ()
#4  0xf7711fe8 in ?? ()       // << This is calling into __libc_get_static_tls_bounds()
#5  0x56587bfe in GetTls () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:434
#6  GetThreadStackAndTls () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:517
#7  0x565999b2 in ThreadStart () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp:51
#8  InitializeMainThread () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp:80
#9  0x565952bc in __lsan_init () at /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/lib/lsan/lsan.cpp:105
#10 0xf7f1a729 in soinfo::call_pre_init_constructors (this=0x3) at bionic/linker/linker_soinfo.cpp:516
#11 0xf7f1a5e5 in soinfo::find_symbol_by_address (this=0xf7d6a010, addr=0xf7ff4008 <__dl__ZZ21__libc_shared_globalsvE7globals+200>)
   from /mnt/ssd/repo/cf_x86_img/out/target/product/vsoc_x86/symbols/apex/com.android.runtime/bin/linker
#12 0xf7f66bef in std::__1::vector<char const*, std::__1::allocator<char const*> >::push_back (this=<optimized out>, __x=<optimized out>)
    at external/libcxx/include/vector:1639
#13 linker_main(KernelArgumentBlock&, char const*)::$_1::operator()(char const*) const (this=<optimized out>, name=0x0) at bionic/linker/linker_main.cpp:446
#14 for_each_dt_needed<linker_main(KernelArgumentBlock&, char const*)::$_1>(soinfo const*, linker_main(KernelArgumentBlock&, char const*)::$_1) (si=<optimized out>, 
    action=...) at bionic/linker/linker_soinfo.h:447
#15 linker_main (args=..., exe_to_load=<optimized out>) at bionic/linker/linker_main.cpp:445
#16 __linker_init_post_relocation (args=..., tmp_linker_so=...) at bionic/linker/linker_main.cpp:743
#17 0xf7f65583 in call_ifunc_resolvers (load_bias=<optimized out>) at bionic/linker/linker_main.cpp:589
#18 __linker_init (raw_args=0xffffd650) at bionic/linker/linker_main.cpp:657
#19 0xf7f1e35b in ?? () from /mnt/ssd/repo/cf_x86_img/out/target/product/vsoc_x86/symbols/apex/com.android.runtime/bin/linker

We could delay finding static TLS until later?

But TBH, I'm not sure why it's calling memalign() from get_static_tls_bounds. There's no allocation whatsoever in that function.

oontvoo updated this revision to Diff 297708.Oct 12 2020, 3:46 PM
oontvoo marked an inline comment as done.

Updated diff:

  • use uptr instead of size_t
  • only weak-decl for pre-21 API

Thanks for the log! This seems to be running with Android 21 (not 16) ...

I've fixed the unknown type errors.

compiler-rt/lib/lsan/lsan_interceptors.cpp
115 ↗(On Diff #297653)

My bad. The only reason it was calling free/memalign was because the libc on my test device had a few printf in it. I'd completely missed it!

This was also hiding the problem that we should not intercept __libc_memalign for android (because it does not exist in bionic and will cause undefined symbol: __libc_memalign. Same goes for cfree ).

More errors: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=318436438&repo=ash&lineNumber=15974
(Please note that there are two different files mentioned -- sanitizer_linux.cpp and sanitizer_linux_libcdep.cpp)

Thanks for the log! This seems to be running with Android 21 (not 16) ...

For reasons that I don't entirely understand, that one task builds compiler-rt for four targets, with two of them at 16 and two at 21.

Sorry, the minimum I could get is 21 for an x86 emulator and ~27 for a real aarch64 test device.
But making this a weak, as eugenis suggested, *should* work. PTAL.

What about only doing the compilation? That shouldn't require any real hardware, right?

oontvoo updated this revision to Diff 297746.Oct 12 2020, 7:40 PM

updated diff

> What about only doing the compilation? That shouldn't require any real hardware, right?

Ok, I think it should be OK now.

I've tried setting -D__ANDROID_API__=16. It built successfully and skipped all the tests.

 local COMPILER_RT_OPTIONS=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt
+ build_android i386
+ local _arch=i386
+ wait
+ cd compiler_rt_build_android_i386
+ cmake -DCMAKE_C_COMPILER=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang++ -DLLVM_CONFIG_PATH=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/llvm-config -DCOMPILER_RT_BUILD_BUILTINS=OFF -DCOMPILER_RT_INCLUDE_TESTS=ON -DCOMPILER_RT_ENABLE_WERROR=ON '-DCMAKE_ASM_FLAGS=--target=i686-linux-android --sysroot=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/sysroot -B/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386' '-DCMAKE_C_FLAGS=--target=i686-linux-android --sysroot=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/sysroot -B/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386' '-DCMAKE_CXX_FLAGS=--target=i686-linux-android --sysroot=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/sysroot -B/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386 -stdlib=libstdc++' -DANDROID=1 -D__ANDROID_API__=16 '-DCOMPILER_RT_TEST_COMPILER_CFLAGS=--target=i686-linux-android --sysroot=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/sysroot -B/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386' -DCOMPILER_RT_TEST_TARGET_TRIPLE=i686-linux-android -DCOMPILER_RT_OUTPUT_DIR=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0 -DCOMPILER_RT_EXEC_OUTPUT_DIR=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin '-DLLVM_LIT_ARGS=-sv --show-unsupported --show-xfail' -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_LINK_JOBS=20 -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_LIBXML2_ENABLED=OFF /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt
.
-- The C compiler identification is Clang 12.0.0
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- The ASM compiler identification is Clang
-- The ASM compiler identification is Clang
-- Found assembler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang
-- Found assembler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang
-- Check for working C compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang
-- Check for working C compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang
-- Check for working C compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang -- works
-- Detecting C compiler ABI info
-- Check for working C compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang++
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang++
-- Check for working CXX compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Check for working CXX compiler: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test LLVM_LIBSTDCXX_MIN
-- Looking for unwind.h
-- Looking for unwind.h - found
-- Looking for rpc/xdr.h
-- Performing Test LLVM_LIBSTDCXX_MIN - Success
-- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
-- Looking for rpc/xdr.h - not found
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")
-- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for fcntl.h
-- Found Python3: /usr/bin/python3.8 (found version "3.8.5") found components: Interpreter 
-- Looking for fopen in c
-- Looking for fcntl.h - found
-- Looking for link.h
-- Looking for fopen in c - found
-- Looking for __gcc_personality_v0 in gcc
-- Looking for link.h - found
-- Looking for malloc/malloc.h
-- Looking for __gcc_personality_v0 in gcc - found
-- Performing Test COMPILER_RT_HAS_NODEFAULTLIBS_FLAG
-- Looking for malloc/malloc.h - not found
-- Looking for pthread.h
-- Performing Test COMPILER_RT_HAS_NODEFAULTLIBS_FLAG - Success
-- Looking for pthread.h - found
-- Performing Test COMPILER_RT_HAS_FFREESTANDING_FLAG
-- Looking for signal.h
-- Performing Test COMPILER_RT_HAS_FFREESTANDING_FLAG - Success
-- Performing Test COMPILER_RT_HAS_STD_C11_FLAG
-- Looking for signal.h - found
-- Looking for sys/ioctl.h
-- Performing Test COMPILER_RT_HAS_STD_C11_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FPIC_FLAG
-- Looking for sys/ioctl.h - found
-- Looking for sys/mman.h
-- Performing Test COMPILER_RT_HAS_FPIC_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FPIE_FLAG
-- Looking for sys/mman.h - found
-- Looking for sys/param.h
-- Performing Test COMPILER_RT_HAS_FPIE_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_BUILTIN_FLAG
-- Looking for sys/param.h - found
-- Looking for sys/resource.h
-- Performing Test COMPILER_RT_HAS_FNO_BUILTIN_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG
-- Looking for sys/resource.h - found
-- Looking for sys/stat.h
-- Performing Test COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG
-- Looking for sys/stat.h - found
-- Looking for sys/time.h
-- Performing Test COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FUNWIND_TABLES_FLAG
-- Looking for sys/time.h - found
-- Looking for sys/types.h
-- Performing Test COMPILER_RT_HAS_FUNWIND_TABLES_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG
-- Looking for sys/types.h - found
-- Looking for sysexits.h
-- Performing Test COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG
-- Looking for sysexits.h - found
-- Looking for termios.h
-- Performing Test COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG
-- Looking for termios.h - found
-- Looking for unistd.h
-- Performing Test COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FRTTI_FLAG
-- Performing Test COMPILER_RT_HAS_FRTTI_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_RTTI_FLAG
-- Looking for unistd.h - found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - not found
-- Looking for fenv.h
-- Performing Test COMPILER_RT_HAS_FNO_RTTI_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG
-- Looking for fenv.h - found
-- Looking for FE_ALL_EXCEPT
-- Performing Test COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG - Success
-- Performing Test COMPILER_RT_HAS_STD_CXX14_FLAG
-- Looking for FE_ALL_EXCEPT - found
-- Looking for FE_INEXACT
-- Performing Test COMPILER_RT_HAS_STD_CXX14_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC
-- Performing Test COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC - Success
-- Looking for FE_INEXACT - found
-- Looking for mach/mach.h
-- Performing Test COMPILER_RT_HAS_FNO_LTO_FLAG
-- Looking for mach/mach.h - not found
-- Looking for histedit.h
-- Performing Test COMPILER_RT_HAS_FNO_LTO_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG
-- Looking for histedit.h - not found
-- Looking for CrashReporterClient.h
-- Looking for CrashReporterClient.h - not found
-- Looking for linux/magic.h
-- Performing Test COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG
-- Looking for linux/magic.h - found
-- Looking for pthread_create in pthread
-- Performing Test COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG - Success
-- Performing Test COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG
-- Looking for pthread_create in pthread - not found
-- Looking for pthread_create in c
-- Performing Test COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG - Success
-- Performing Test COMPILER_RT_HAS_MSSE3_FLAG
-- Looking for pthread_create in c - found
-- Looking for pthread_getspecific in c
-- Performing Test COMPILER_RT_HAS_MSSE3_FLAG - Success
-- Performing Test COMPILER_RT_HAS_MSSE4_2_FLAG
-- Looking for pthread_getspecific in c - found
-- Looking for pthread_rwlock_init in c
-- Performing Test COMPILER_RT_HAS_MSSE4_2_FLAG - Success
-- Performing Test COMPILER_RT_HAS_SYSROOT_FLAG
-- Looking for pthread_rwlock_init in c - found
-- Looking for pthread_mutex_lock in c
-- Performing Test COMPILER_RT_HAS_SYSROOT_FLAG - Success
-- Performing Test COMPILER_RT_HAS_MCRC_FLAG
-- Looking for pthread_mutex_lock in c - found
-- Looking for dlopen in dl
-- Performing Test COMPILER_RT_HAS_MCRC_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_FNO_PARTIAL_INLINING_FLAG
-- Performing Test COMPILER_RT_HAS_FNO_PARTIAL_INLINING_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Looking for dlopen in dl - found
-- Looking for clock_gettime in rt
-- Performing Test COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Performing Test COMPILER_RT_HAS_GR_FLAG
-- Looking for clock_gettime in rt - not found
-- Looking for pfm_initialize in pfm
-- Performing Test COMPILER_RT_HAS_GR_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_GS_FLAG
-- Performing Test COMPILER_RT_HAS_GS_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_MT_FLAG
-- Looking for pfm_initialize in pfm - not found
-- Performing Test COMPILER_RT_HAS_MT_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_Oy_FLAG
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Looking for xar_open in xar
-- Performing Test COMPILER_RT_HAS_Oy_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG
-- Looking for xar_open in xar - not found
-- Looking for arc4random
-- Performing Test COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG - Success
-- Performing Test COMPILER_RT_HAS_G_FLAG
-- Performing Test COMPILER_RT_HAS_G_FLAG - Success
-- Performing Test COMPILER_RT_HAS_Zi_FLAG
-- Looking for arc4random - found
-- Looking for backtrace
-- Performing Test COMPILER_RT_HAS_Zi_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WALL_FLAG
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY) 
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test COMPILER_RT_HAS_WALL_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WERROR_FLAG
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Success
-- Looking for _Unwind_Backtrace
-- Performing Test COMPILER_RT_HAS_WERROR_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG
-- Looking for _Unwind_Backtrace - found
-- Looking for getpagesize
-- Performing Test COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG
-- Looking for getpagesize - found
-- Looking for sysconf
-- Performing Test COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG
-- Looking for sysconf - found
-- Looking for getrusage
-- Performing Test COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WGNU_FLAG
-- Looking for getrusage - found
-- Looking for setrlimit
-- Performing Test COMPILER_RT_HAS_WGNU_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG
-- Looking for setrlimit - found
-- Looking for isatty
-- Performing Test COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG
-- Looking for isatty - found
-- Looking for futimens
-- Performing Test COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG
-- Looking for futimens - found
-- Looking for futimes
-- Performing Test COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG
-- Looking for futimes - not found
-- Looking for posix_fallocate
-- Performing Test COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG
-- Looking for posix_fallocate - found
-- Looking for sigaltstack
-- Performing Test COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG - Success
-- Performing Test COMPILER_RT_HAS_WNO_PEDANTIC
-- Looking for sigaltstack - found
-- Looking for lseek64
-- Performing Test COMPILER_RT_HAS_WNO_PEDANTIC - Success
-- Performing Test COMPILER_RT_HAS_W4_FLAG
-- Looking for lseek64 - found
-- Looking for mallctl
-- Performing Test COMPILER_RT_HAS_W4_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WX_FLAG
-- Performing Test COMPILER_RT_HAS_WX_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WD4146_FLAG
-- Looking for mallctl - not found
-- Looking for mallinfo
-- Performing Test COMPILER_RT_HAS_WD4146_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WD4291_FLAG
-- Looking for mallinfo - found
-- Looking for malloc_zone_statistics
-- Performing Test COMPILER_RT_HAS_WD4291_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WD4221_FLAG
-- Performing Test COMPILER_RT_HAS_WD4221_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WD4391_FLAG
-- Looking for malloc_zone_statistics - not found
-- Looking for getrlimit
-- Performing Test COMPILER_RT_HAS_WD4391_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WD4722_FLAG
-- Looking for getrlimit - found
-- Looking for posix_spawn
-- Performing Test COMPILER_RT_HAS_WD4722_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_WD4800_FLAG
-- Performing Test COMPILER_RT_HAS_WD4800_FLAG - Failed
-- Looking for __func__
-- Looking for posix_spawn - not found
-- Looking for pread
-- Looking for __func__ - found
-- Performing Test COMPILER_RT_HAS_NOSTDINCXX_FLAG
-- Looking for pread - found
-- Looking for sbrk
-- Looking for sbrk - found
-- Looking for strerror
-- Performing Test COMPILER_RT_HAS_NOSTDINCXX_FLAG - Success
-- Looking for include file sys/auxv.h
-- Looking for strerror - found
-- Looking for strerror_r
-- Looking for include file sys/auxv.h - found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Looking for shm_open in rt
-- Looking for strerror_r - found
-- Looking for strerror_s
-- Looking for strerror_s - not found
-- Looking for setenv
-- Looking for shm_open in rt - not found
-- Looking for pow in m
-- Looking for pow in m - found
-- Looking for pthread_create in pthread
-- Looking for setenv - found
-- Looking for dlopen
-- Looking for pthread_create in pthread - not found
-- Looking for backtrace in execinfo
-- Looking for dlopen - found
-- Looking for dladdr
-- Looking for backtrace in execinfo - not found
-- Looking for __cxa_throw in c++
-- Looking for dladdr - found
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - Failed
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-- Looking for __cxa_throw in c++ - not found
-- Looking for __cxa_throw in stdc++
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - Success
-- Looking for __GLIBC__
-- Looking for __cxa_throw in stdc++ - found
-- Performing Test COMPILER_RT_HAS_Z_TEXT
-- Looking for __GLIBC__ - not found
-- Looking for pthread_getname_np
-- Performing Test COMPILER_RT_HAS_Z_TEXT - Success
-- Performing Test COMPILER_RT_HAS_FUSE_LD_LLD_FLAG
-- Looking for pthread_getname_np - not found
-- Looking for pthread_setname_np
-- Performing Test COMPILER_RT_HAS_FUSE_LD_LLD_FLAG - Success
-- Performing Test COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT
-- Looking for pthread_setname_np - found
-- Performing Test HAVE_STD_IS_TRIVIALLY_COPYABLE
-- Performing Test COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT - Failed
-- Performing Test COMPILER_RT_HAS_VERSION_SCRIPT
-- Performing Test COMPILER_RT_HAS_VERSION_SCRIPT - Success
-- Performing Test HAVE_STD_IS_TRIVIALLY_COPYABLE - Success
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test COMPILER_RT_HAS_Z_GLOBAL
-- Performing Test COMPILER_RT_HAS_Z_GLOBAL - Success
-- Looking for __android_log_write in log
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Looking for __android_log_write in log - found
-- Looking for __arm__
-- Looking for __arm__ - not found
-- Looking for __aarch64__
-- Looking for __aarch64__ - not found
-- Looking for __x86_64__
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Looking for __x86_64__ - not found
-- Looking for __i386__
-- Performing Test LLVM_HAS_ATOMICS - Success
-- Performing Test SUPPORTS_VARIADIC_MACROS_FLAG
-- Looking for __i386__ - found
-- Looking for __mips__
-- Looking for __mips__ - not found
-- Looking for __mips64__
-- Performing Test SUPPORTS_VARIADIC_MACROS_FLAG - Success
-- Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG
-- Looking for __mips64__ - not found
-- Looking for __powerpc__
-- Looking for __powerpc__ - not found
-- Looking for __powerpc64__
-- Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG - Success
-- Looking for __powerpc64__ - not found
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Looking for __powerpc64le__
-- Looking for __powerpc64le__ - not found
-- Looking for __riscv
-- Looking for __riscv - not found
-- Looking for __s390x__
-- Looking for __s390x__ - not found
-- Looking for __sparc
-- Looking for __sparc - not found
-- Looking for __sparcv9
-- Looking for __sparcv9 - not found
-- Looking for __wasm32__
-- Looking for __wasm32__ - not found
-- Looking for __wasm64__
-- Go bindings enabled.
-- Ninja version: 1.10.0
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- OCaml bindings disabled.
-- Looking for __wasm64__ - not found
-- Looking for __ve__
-- Could NOT find Python module pygments
-- Could NOT find Python module pygments.lexers.c_cpp
-- Could NOT find Python module yaml
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Performing Test C_SUPPORTS_FPIC
-- Looking for __ve__ - not found
-- Compiler-RT supported architectures: i386
-- Performing Test C_SUPPORTS_FPIC - Success
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test COMPILER_RT_TARGET_HAS_ATOMICS
-- Performing Test COMPILER_RT_TARGET_HAS_ATOMICS - Success
-- Performing Test COMPILER_RT_TARGET_HAS_FCNTL_LCK
-- Performing Test CXX_SUPPORTS_FPIC - Success
-- Building with -fPIC
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME
-- Performing Test COMPILER_RT_TARGET_HAS_FCNTL_LCK - Success
-- Performing Test COMPILER_RT_TARGET_HAS_UNAME
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME
-- Performing Test COMPILER_RT_TARGET_HAS_UNAME - Success
-- Performing Test HAS_THREAD_LOCAL
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test HAS_THREAD_LOCAL - Failed
-- Linker detection: GNU ld
-- check-interception does nothing.
-- Generated Sanitizer SUPPORTED_TOOLS list on "Linux" is "asan;lsan;ubsan"
CMake Warning (dev) at test/sanitizer_common/CMakeLists.txt:41 (message):
  Replacing Sanitizer SUPPORTED_TOOLS list (asan;lsan;ubsan) with "asan"
This warning is for project developers.  Use -Wno-dev to suppress it.

-- sanitizer_common tests on "Linux" will run against "asan"
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Success
-- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG
-- check-scudo_standalone does nothing.
-- check-shadowcallstack does nothing.
-- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG - Success
-- Performing Test C_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG
-- Configuring done
-- Performing Test C_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG - Success
-- Performing Test CXX_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG
-- Performing Test CXX_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG - Success
-- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    LLVM_LIBXML2_ENABLED
    LLVM_PARALLEL_LINK_JOBS
    __ANDROID_API__


-- Build files have been written to: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386
-- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success
-- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
-- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success
-- Performing Test CXX_SUPPORTS_CLASS_MEMACCESS_FLAG
-- Performing Test CXX_SUPPORTS_CLASS_MEMACCESS_FLAG - Failed
-- Performing Test CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG
-- Performing Test CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG - Success
-- Performing Test CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR
-- Performing Test CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR - Success
-- Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG
-- Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Success
-- Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG
-- Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Success
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG - Success
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL - Success
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Success
-- Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG
-- Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG - Success
-- Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG
-- Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG - Success
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Failed
-- Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS
-- Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS - Success
-- Performing Test C_SUPPORTS_FFUNCTION_SECTIONS
-- Performing Test C_SUPPORTS_FFUNCTION_SECTIONS - Success
-- Performing Test CXX_SUPPORTS_FFUNCTION_SECTIONS
-- Performing Test CXX_SUPPORTS_FFUNCTION_SECTIONS - Success
-- Performing Test C_SUPPORTS_FDATA_SECTIONS
-- Performing Test C_SUPPORTS_FDATA_SECTIONS - Success
-- Performing Test CXX_SUPPORTS_FDATA_SECTIONS
-- Performing Test CXX_SUPPORTS_FDATA_SECTIONS - Success
-- Looking for os_signpost_interval_begin
-- Looking for os_signpost_interval_begin - not found
-- Found Python3: /usr/bin/python3.8 (found version "3.8.5") found components: Interpreter 
-- Constructing LLVMBuild project information
-- Linker detection: GNU ld
-- Found Git: /usr/bin/git (found version "2.28.0.1011.ga647a8990f-goog") 
-- Targeting AArch64
-- Targeting AMDGPU
-- Targeting ARM
-- Targeting AVR
-- Targeting BPF
-- Targeting Hexagon
-- Targeting Lanai
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting RISCV
-- Targeting Sparc
-- Targeting SystemZ
-- Targeting WebAssembly
-- Targeting X86
-- Targeting XCore
-- Registering Bye as a pass plugin (static build: OFF)
-- Version: 0.0.0
-- Performing Test HAVE_CXX_FLAG_STD_CXX11
-- Performing Test HAVE_CXX_FLAG_STD_CXX11 - Success
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Success
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL - Success
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS - Success
-- Performing Test HAVE_CXX_FLAG_WNO_SUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_FLAG_WNO_SUGGEST_OVERRIDE - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Success
-- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES
-- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES
-- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES -- failed to compile
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Warning at utils/benchmark/CMakeLists.txt:248 (message):
  Using std::regex with exceptions disabled is not fully supported


-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- compiled but failed to run
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    LLVM_LIBXML2_ENABLED


-- Build files have been written to: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build_android_i386
+ echo @@@BUILD_STEP build android/i386@@@
@@@BUILD_STEP build android/i386@@@
+ ninja -C llvm_build_android_i386 llvm-symbolizer
ninja: Entering directory `llvm_build_android_i386'
[538/538] Linking CXX executable bin/llvm-symbolizer
+ ninja -C compiler_rt_build_android_i386
ninja: Entering directory `compiler_rt_build_android_i386'
[451/451] Linking CXX executable lib/asan/tests/AsanTest
+ test_android i386:x86
+ [[ '' != '' ]]
+ ADB=adb
+ echo @@@BUILD_STEP run all tests@@@
@@@BUILD_STEP run all tests@@@
++ grep 'device$'
++ adb devices
++ awk '{print $1}'
+ ANDROID_DEVICES=127.0.0.1:36473
+ rm -rf test_android_log_q0Jp
+ rm -rf tested_arch_i386
+ rm -rf 'shards_*'
+ LOGS=
+ for SERIAL in $ANDROID_DEVICES
++ mktemp test_android_log_XXXX
+ LOG=test_android_log_FxU6
+ LOGS=' test_android_log_FxU6,1056292'
+ tail_pids ' test_android_log_FxU6,1056292'
+ for LOG_PID in $1
+ test_on_device 127.0.0.1:36473 i386:x86
+ PID=1056292
+ LOG=test_android_log_FxU6
+ tail -n +1 -F test_android_log_FxU6 --pid=1056292
+ local _serial=127.0.0.1:36473
+ shift
++ adb -s 127.0.0.1:36473 shell getprop ro.product.cpu.abilist
+ ABILIST=x86,armeabi-v7a,armeabi
+ patch_abilist x86,armeabi-v7a,armeabi ABILIST
+ local _abilist=x86,armeabi-v7a,armeabi
+ local _out=ABILIST
+ [[ x86,armeabi-v7a,armeabi == \x\8\6\,* ]]
+ _abilist=x86
+ eval 'ABILIST='\''x86'\'''
++ ABILIST=x86
+ for _arg in "$@"
+ local _arch=i386
+ local _abi=x86
+ [[ x86 == *\x\8\6* ]]
+ echo 127.0.0.1:36473
++ adb -s 127.0.0.1:36473 shell getprop ro.build.id
++ tr -d '\r'
+ BUILD_ID=AOSP.MASTER
++ adb -s 127.0.0.1:36473 shell getprop ro.build.flavor
++ tr -d '\r'
+ BUILD_FLAVOR=aosp_cf_x86_phone-userdebug
+ test_arch_on_device i386 127.0.0.1:36473 AOSP.MASTER aosp_cf_x86_phone-userdebug
+ local _arch=i386
+ local _serial=127.0.0.1:36473
+ local _build_id=AOSP.MASTER
+ local _build_flavor=aosp_cf_x86_phone-userdebug
+ export DEVICE_DESCRIPTION=i386/aosp_cf_x86_phone-userdebug/AOSP.MASTER
+ DEVICE_DESCRIPTION=i386/aosp_cf_x86_phone-userdebug/AOSP.MASTER
+ ANDROID_TOOLCHAIN=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386
++ find /usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/ -name libc++_shared.so
++ head -1
+ LIBCXX_SHARED=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/i686-linux-android/lib/libc++_shared.so
+ SYMBOLIZER_BIN=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build_android_i386/bin/llvm-symbolizer
++ /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/bin/clang -print-resource-dir
+ RT_DIR=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux
+ COMPILER_RT_BUILD_DIR=/usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386
+ export ADB=adb
+ ADB=adb
+ export DEVICE_ROOT=/data/local/tmp/Output
+ DEVICE_ROOT=/data/local/tmp/Output
+ export ANDROID_SERIAL=127.0.0.1:36473
+ ANDROID_SERIAL=127.0.0.1:36473
+ echo 'Serial 127.0.0.1:36473'
Serial 127.0.0.1:36473
+ echo @@@BUILD_STEP device setup '[i386/aosp_cf_x86_phone-userdebug/AOSP.MASTER]@@@'
@@@BUILD_STEP device setup [i386/aosp_cf_x86_phone-userdebug/AOSP.MASTER]@@@
+ adb wait-for-device
+ adb devices
List of devices attached
127.0.0.1:36473	device

+ adb shell pkill llvm-symbolizer
+ true
+ adb shell rm -rf /data/local/tmp/Output
+ adb shell mkdir /data/local/tmp/Output
+ FILES='/usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build_android_i386/bin/llvm-symbolizer
         /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.*-android.so
         /usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/i686-linux-android/lib/libc++_shared.so
         /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386/lib/sanitizer_common/tests/SanitizerTest
         /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386/lib/asan/tests/AsanTest
         /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386/lib/asan/tests/AsanNoinstTest'
+ for F in $FILES
+ for F in $FILES
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build_android_i386/bin/llvm-symbolizer /data/local/tmp/Output/
+ for F in $FILES
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.asan-i686-android.so /data/local/tmp/Output/
+ for F in $FILES
+ for F in $FILES
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.scudo-i686-android.so /data/local/tmp/Output/
+ for F in $FILES
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.ubsan_minimal-i686-android.so /data/local/tmp/Output/
+ for F in $FILES
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.ubsan_standalone-i686-android.so /data/local/tmp/Output/
+ for F in $FILES
+ for F in $FILES
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.scudo_minimal-i686-android.so /data/local/tmp/Output/
+ for F in $FILES
+ wait
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/android_ndk/standalone-i386/i686-linux-android/lib/libc++_shared.so /data/local/tmp/Output/
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386/lib/sanitizer_common/tests/SanitizerTest /data/local/tmp/Output/
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386/lib/asan/tests/AsanTest /data/local/tmp/Output/
+ adb push /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386/lib/asan/tests/AsanNoinstTest /data/local/tmp/Output/
+ echo @@@BUILD_STEP run lit tests '[i386/aosp_cf_x86_phone-userdebug/AOSP.MASTER]@@@'
@@@BUILD_STEP run lit tests [i386/aosp_cf_x86_phone-userdebug/AOSP.MASTER]@@@
+ cd /usr/local/google/home/vyng/repo/i686_buildbot/rundir/compiler_rt_build_android_i386
+ ninja check-lsan
[0/1] Running the LeakSanitizer tests
llvm-lit: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/test/lit.common.cfg.py:219: warning: %device_rm is not implemented
llvm-lit: /usr/local/google/home/vyng/repo/i686_buildbot/rundir/llvm-project/compiler-rt/test/lit.common.cfg.py:219: warning: %device_rm is not implemented
-- Testing: 94 tests, 6 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

2 warning(s) in tests
********************
Unsupported Tests (94):
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Darwin/dispatch.mm
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/cleanup_in_tsd_destructor.c
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/disabler_in_tsd_destructor.c
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/fork.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/fork_and_leak.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/fork_threaded.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/guard-page.c
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/libdl_deadlock.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/log-path_test.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/use_tls_dynamic.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/use_tls_pthread_specific_dynamic.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/use_tls_pthread_specific_static.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/Linux/use_tls_static.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/default_options.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/disabler.c
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/disabler.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/do_leak_check_override.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/high_allocator_contention.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/ignore_object.c
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/ignore_object_errors.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/large_allocation_leak.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/leak_check_at_exit.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/leak_check_before_thread_started.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/link_turned_off.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/many_threads_detach.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/many_tls_keys_pthread.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/many_tls_keys_thread.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/new_array_with_dtor_0.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/pointer_to_self.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/print_suppressions.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/recoverable_leak_check.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/register_root_region.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/sanity_check_pure_c.c
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/stale_stack_leak.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/strace_test.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/suppressions_default.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/suppressions_file.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/swapcontext.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_after_return.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_globals_initialized.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_globals_uninitialized.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_poisoned_asan.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_registers.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_registers_extra.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_stacks.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_stacks_threaded.cpp
  LeakSanitizer-AddressSanitizer-i386 :: TestCases/use_unaligned.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Darwin/dispatch.mm
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/cleanup_in_tsd_destructor.c
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/disabler_in_tsd_destructor.c
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/fork.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/fork_and_leak.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/fork_threaded.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/guard-page.c
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/libdl_deadlock.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/log-path_test.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/use_tls_dynamic.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/use_tls_pthread_specific_dynamic.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/use_tls_pthread_specific_static.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/Linux/use_tls_static.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/default_options.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/disabler.c
  LeakSanitizer-Standalone-i386 :: TestCases/disabler.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/do_leak_check_override.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/high_allocator_contention.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/ignore_object.c
  LeakSanitizer-Standalone-i386 :: TestCases/ignore_object_errors.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/large_allocation_leak.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/leak_check_at_exit.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/leak_check_before_thread_started.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/link_turned_off.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/many_threads_detach.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/many_tls_keys_pthread.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/many_tls_keys_thread.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/new_array_with_dtor_0.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/pointer_to_self.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/print_suppressions.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/recoverable_leak_check.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/register_root_region.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/sanity_check_pure_c.c
  LeakSanitizer-Standalone-i386 :: TestCases/stale_stack_leak.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/strace_test.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/suppressions_default.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/suppressions_file.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/swapcontext.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_after_return.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_globals_initialized.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_globals_uninitialized.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_poisoned_asan.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_registers.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_registers_extra.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_stacks.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_stacks_threaded.cpp
  LeakSanitizer-Standalone-i386 :: TestCases/use_unaligned.cpp


Testing Time: 0.06s
  Unsupported: 94
+ wait
+ for _arg in "$@"
+ local _arch=i386
+ [[ ! -f tested_arch_i386 ]]
dmajor added a comment.EditedOct 12 2020, 9:01 PM

[EDIT: This is specific to the armv7-linux-android target]

Looks like it's having trouble with the thread-local machinery:

[task 2020-10-13T03:33:02.874Z] ld.lld: error: undefined symbol: __aeabi_read_tp
[task 2020-10-13T03:33:02.874Z] >>> referenced by lsan_common_linux.cpp:54 (/builds/worker/fetches/llvm-project/llvm/runtimes/compiler-rt/lib/lsan/lsan_common_linux.cpp:54)
[task 2020-10-13T03:33:02.874Z] >>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.arm.dir/lsan_common_linux.cpp.o:(__lsan::DisabledInThisThread())
[task 2020-10-13T03:33:02.874Z] >>> referenced by lsan_common_linux.cpp:65 (/builds/worker/fetches/llvm-project/llvm/runtimes/compiler-rt/lib/lsan/lsan_common_linux.cpp:65)
[task 2020-10-13T03:33:02.874Z] >>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.arm.dir/lsan_common_linux.cpp.o:(__lsan::DisableInThisThread())
[task 2020-10-13T03:33:02.874Z] >>> referenced by lsan_common_linux.cpp:73 (/builds/worker/fetches/llvm-project/llvm/runtimes/compiler-rt/lib/lsan/lsan_common_linux.cpp:73)
[task 2020-10-13T03:33:02.874Z] >>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.arm.dir/lsan_common_linux.cpp.o:(__lsan::EnableInThisThread()

https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=318445471&repo=ash&lineNumber=16202

oontvoo updated this revision to Diff 297759.Oct 12 2020, 9:32 PM

updated diff

oontvoo added a comment.EditedOct 12 2020, 9:36 PM

[EDIT: This is specific to the armv7-linux-android target]

arm32?

Looks like it's having trouble with the thread-local machinery:

We've turnt off emulated-tls (and use "real" ELF TLS) for Android in the previous patch. Tested it on aarch64/API_LEVEL 27 and it did not have an issue. :-(
At this point, I'm not sure we could avoid hard-coding the minimum supported API level for LSAN, so I'm going to put back the check.

[Edit:] s/of/off

The build bot is happy with Diff 6! \o/

The build bot is happy with Diff 6! \o/

Cool! Thanks for the patience! And since the original commit was revert, I think I'll move the reland into this revision too.

oontvoo retitled this revision from [lsan] Do not enable leak-sanitizer if api_level is less than 29. to Reland [lsan] Enable LSAN for Android.Oct 13 2020, 8:49 AM
oontvoo edited the summary of this revision. (Show Details)
srhines accepted this revision.Oct 13 2020, 10:20 AM

I think this is ok, but I'd like @eugenis to confirm that he is fine with it too. Thanks for explaining the complexity across the different API levels.

This revision is now accepted and ready to land.Oct 13 2020, 10:20 AM
compiler-rt/lib/lsan/lsan_common.h
43

Is this bit necessary? Arm64 links fine without the api level requirement, right?
I'm OK with not supporting arm32, leak detection on 32-bit targets is flaky anyway (random data is likely to look like a pointer).

Or am I just confused by the operator precedence? Please add more parentheses.

compiler-rt/lib/lsan/lsan_interceptors.cpp
137 ↗(On Diff #297759)

This is too much nested ifdefs.
Please split the memalign section into memalign and libc_memalign.

oontvoo updated this revision to Diff 297964.Oct 13 2020, 2:43 PM
oontvoo marked 2 inline comments as done.
oontvoo edited the summary of this revision. (Show Details)

Updated diff.
Also included the previously reverted patch.

oontvoo updated this revision to Diff 297965.Oct 13 2020, 2:45 PM

updated diff

eugenis added inline comments.Oct 13 2020, 3:58 PM
compiler-rt/lib/lsan/lsan_common.h
43

Mention the link problems due to TLS. Leak detection is flaky on all 32-bit platforms, but we don't disable it just because of that.
(also because the flakes are false-negative, not false-positive, so they make the tool less useful but, strictly speaking, not broken)

compiler-rt/lib/lsan/lsan_common_linux.cpp
108

"turned"

compiler-rt/lib/lsan/lsan_interceptors.cpp
122 ↗(On Diff #297965)

Two more underscores.
INTERCEPT___LIBC_MEMALIGN

115 ↗(On Diff #297653)

It's only a warning, right?
ASan intercepts these function and it is doing just fine.
Anyway, if they do not exist on any of the supported versions (going back to L), then it's good to remove the interceptors.

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107

Hmm, this !SANITIZER_ANDROID here goes way back, and I'm not sure why. Must be something about linking the runtime as a shared library, which was once unique to android.

I think this is correct, but how did you run into this?

compiler-rt/lib/sanitizer_common/sanitizer_linux.h
156

We don't really know if it will be 31 or something else. Let's call is "S" for now.

compiler-rt/test/lit.common.cfg.py
69 ↗(On Diff #297965)

The bots use ANDROID_SERIAL environment variable to pick the device, but please use os.environ.get('ADB', 'adb').

oontvoo updated this revision to Diff 298002.Oct 13 2020, 6:01 PM
oontvoo marked 6 inline comments as done.

updated diff

compiler-rt/lib/lsan/lsan_interceptors.cpp
115 ↗(On Diff #297653)

It's only a warning, right?

Weirdly, no, it's a dlerror. (This made the use_tls_dynamic.cpp test fail).

Anyway, if they do not exist on any of the supported versions (going back to L), then it's good to remove the interceptors.

cfree can definitely be removed. Even glibc says so.
Not too sure about __libc_memalign

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107

Hmm, this !SANITIZER_ANDROID here goes way back, and I'm not sure why. Must be something about linking the runtime as a shared library, which was once unique to android.

How do we verify that this change wouldn't blow up in some unexpected way?

I think this is correct, but how did you run into this?

Standalone LSAN was segfaulting.
As it turned out, LSAN uses .prenit_array to ensure __lsan_init is called before everything else.
If we don't remove this !SANITIZER_ANDROID then Standalone LSAN would never init for Android.

eugenis added inline comments.Oct 13 2020, 7:14 PM
compiler-rt/lib/lsan/lsan_interceptors.cpp
115 ↗(On Diff #297653)

OK. The problem is that if cfree is defined in libc.so and used, and we do not intercept it, we are going to crash in a weird way.

Not sure where the dlerror comes from. See ASAN_INTERCEPT_FUNC - interception failures should not be fatal.

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107

Right. Asan is initialized by inserting constructors in each instrumented module. Standalone lsan can not do this.

Check that we do not insert a preinit_array in the shared runtime library. But I think the linker should check this for us.

oontvoo marked an inline comment as done.Oct 13 2020, 8:00 PM
oontvoo added inline comments.
compiler-rt/lib/lsan/lsan_interceptors.cpp
115 ↗(On Diff #297653)

OK. The problem is that if cfree is defined in libc.so and used, and we do not intercept it, we are going to crash in a weird way.

So we'll leave the cfree and __libc_memalign interceptors for non-android, and skip them on Android.
That should be ok, yes?

Not sure where the dlerror comes from. See ASAN_INTERCEPT_FUNC - interception failures should not be fatal.

Sorry, I should've been more specific. It's not fatal or anything but if app uses dlopen/dlsym and then calls dlerror() expecting to see nullptr (for success), it won't happen. Instead, dlerror() will return the interception failure message ("undefined symbol: __libc_memalign" or "undefined symbol: cfree").
That would be very confusing to users.

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107

Check that we do not insert a preinit_array in the shared runtime library.

The libclang_rt-*asan.so ? I don't see any preinit_array section in it:

 objdump -D -j .preinit_array ./llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.asan-i686-android.so

./llvm_build64/lib/clang/12.0.0/lib/linux/libclang_rt.asan-i686-android.so:     file format elf32-i386

objdump: section '.preinit_array' mentioned in a -j option, but not found in any input file

It does exist in the libclang_rt.lsan-i686-android.a

oontvoo updated this revision to Diff 298428.Oct 15 2020, 11:37 AM
oontvoo marked an inline comment as done.

rebase

vitalybuka requested changes to this revision.Oct 15 2020, 6:45 PM
vitalybuka added a subscriber: vitalybuka.

A lot of tests fails like:

/usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/compiler-rt/test/sanitizer_common/android_commands/android_compile.py  /usr/local/google/home/vitalybuka/slow/bbot/llvm_build64/bin/clang  --driver-mode=g++ -stdlib=libstdc++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -pie -fuse-ld=gold --target=i686-linux-android --sysroot=/usr/local/google/home/vitalybuka/slow/bbot/android_ndk/standalone-i686/sysroot -B/usr/local/google/home/vitalybuka/slow/bbot/android_ndk/standalone-i686 -fuse-ld=lld  -shared-libasan -O1 -fsanitize-address-use-after-scope /usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/compiler-rt/test/asan/TestCases/use-after-scope-nobug.cpp -o /usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp &&  /usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp
WARNING: linker: /data/local/tmp/Output/usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp: unsupported flags DT_FLAGS_1=0x8000001
CANNOT LINK EXECUTABLE "/data/local/tmp/Output/usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp": unknown reloc type 14 @ 0xa8d63390 (638)
Aborted 
Aborted

It's from https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

This revision now requires changes to proceed.Oct 15 2020, 6:45 PM

I recommend to extract smaller patches which can be landed separately.

A lot of tests fails like:

/usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/compiler-rt/test/sanitizer_common/android_commands/android_compile.py  /usr/local/google/home/vitalybuka/slow/bbot/llvm_build64/bin/clang  --driver-mode=g++ -stdlib=libstdc++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -pie -fuse-ld=gold --target=i686-linux-android --sysroot=/usr/local/google/home/vitalybuka/slow/bbot/android_ndk/standalone-i686/sysroot -B/usr/local/google/home/vitalybuka/slow/bbot/android_ndk/standalone-i686 -fuse-ld=lld  -shared-libasan -O1 -fsanitize-address-use-after-scope /usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/compiler-rt/test/asan/TestCases/use-after-scope-nobug.cpp -o /usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp &&  /usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp
WARNING: linker: /data/local/tmp/Output/usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp: unsupported flags DT_FLAGS_1=0x8000001

CANNOT LINK EXECUTABLE "/data/local/tmp/Output/usr/local/google/home/vitalybuka/slow/bbot/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Output/use-after-scope-nobug.cpp.tmp": unknown reloc type 14 @ 0xa8d63390 (638)
Aborted 
Aborted

Can you share the version of the x86 emulator it was using? (http://lab.llvm.org:8011/buildslaves/sanitizer-buildbot1 threw No such resource for me)
Is it pre-28?

oontvoo added a comment.EditedOct 16 2020, 11:09 PM

I recommend to extract smaller patches which can be landed separately.

Split off the cmake and lit to DD89615
And moved the interceptors stuff to D89616

PTAL

Re: failures:

The issue was that -fno-emulated-tls was set, even for older Android. DD89615 will also take care of not setting that for older android

vitalybuka added inline comments.Oct 20 2020, 1:41 AM
compiler-rt/lib/lsan/lsan_common_linux.cpp
37

why this need to be weak?

61–65
// LSAN is only enabled with Android-S and up.
if (!HAS_ANDROID_THREAD_PROPERTIES_API)
  return;
106–111
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107–108

please clang-format

compiler-rt/test/lsan/TestCases/Linux/log-path_test.cpp
10 ↗(On Diff #298808)

Is this some debug leftover?
This test is executed by any linux build and going to fail on non-undroid.

compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
22–25 ↗(On Diff #298808)

Could you remove this change to avoid unnececary ifdef

compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
9 ↗(On Diff #298808)

inconsistent spaces

compiler-rt/test/lsan/TestCases/use_registers.cpp
27 ↗(On Diff #298808)

inconsistent formatting

oontvoo updated this revision to Diff 299379.Oct 20 2020, 9:02 AM
oontvoo marked 9 inline comments as done.

updated diff

compiler-rt/lib/lsan/lsan_common_linux.cpp
37

Because older Androids do not have dl_iterate_phdr. They will get a compilation error. (dmajor@ shared the error log a few comments back).
It's worth noting that we're already doing this weak-decl for dl_iterate_phdr in quite a few other places.

61–65
// LSAN is only enabled with Android-S and up.
if (!HAS_ANDROID_THREAD_PROPERTIES_API)
  return;

Still need the SANITIZER_ANDROID because
HAS_ANDROID_THREAD_PROPERTIES_API will be false on Non-Android, which means we'd always disable.

106–111

Sorry, why do you want to change the compile-time condition to a runtime check?
We probably don't want to pay this cost if it's not Android.

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107–108

Done.

compiler-rt/test/lsan/TestCases/Linux/log-path_test.cpp
10 ↗(On Diff #298808)

Is this some debug leftover?

No. :)

This test is executed by any linux build and going to fail on non-undroid.

On non-android, these macros are mostly no-op.
The run command on line 15 wants to FileCheck a *local* path, which it will not see if we're testing Android, because the log is on the device. So all these new additions are to pull the file from the target device back to the host.

compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
22–25 ↗(On Diff #298808)

No, because without this condition, the test will fail on Android, as this assertion does not apply to Bionic.

vitalybuka added inline comments.Oct 20 2020, 2:19 PM
compiler-rt/lib/lsan/lsan_common_linux.cpp
37

@eugenis Why do we care about compiling with old API?

61–65

Oh, you use this to completely shutdown lsan on pre-S
I think it's better to abort with error on initialization with error message, if lsan is enabled and not S.

I don't like the user may think that lsan is enabled when it's not.

106–111

SANITIZER_ANDROID is compile time constant, it will have no runtime overhead
However normal if looks better and and compiles/validates code on all platforms.

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107–108

I expected !defined(PIC) on a previous line, but please keep whatever is done clang-format

compiler-rt/test/lsan/TestCases/Linux/log-path_test.cpp
10 ↗(On Diff #298808)

I tried previous snapshot on Linux and it failed. I see you just added these substitutions :)

compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
22–25 ↗(On Diff #298808)

oh, sorry, you didn't add the assert
I would say just remove the assert everywhere, but up to you.

eugenis added inline comments.Oct 20 2020, 2:23 PM
compiler-rt/lib/lsan/lsan_common_linux.cpp
37

Because we do not want to ship a copy of the runtime library for every sdk level.
NDK currently ships a single copy - it's part of the toolchain and not of the sysroot.

vitalybuka added inline comments.Oct 20 2020, 2:33 PM
compiler-rt/lib/lsan/lsan_common_linux.cpp
37

This is compile time check. Do you mean we ship different runtime for each API level?

oontvoo updated this revision to Diff 299513.Oct 20 2020, 4:38 PM
oontvoo marked 5 inline comments as done.

updated diff

compiler-rt/lib/lsan/lsan_common_linux.cpp
61–65

Oh, you use this to completely shutdown lsan on pre-S

Yes

I think it's better to abort with error on initialization with error message, if lsan is enabled and not S.

LSAN is enabled unconditionally. (Same reason as eugenis@ has given wrt. shipping same runtime for different versions).
As such, we can't error out here because users on pre-S (which is to say everybody right now) will get an error.

I don't like the user may think that lsan is enabled when it's not.

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
107–108

Pulling !defined(PIC) to the next line was clang-format's doing.
(Not sure why - it clearly fits within 80 character)

compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
22–25 ↗(On Diff #298808)

oh, sorry, you didn't add the assert
I would say just remove the assert everywhere, but up to you.

compiler-rt/test/lsan/TestCases/use_registers.cpp
27 ↗(On Diff #298808)

(This, again, was also clang-format)

srhines added inline comments.Oct 20 2020, 5:03 PM
compiler-rt/lib/lsan/lsan_common_linux.cpp
37

No. It gets built for the lowest supported level generally, and we ship that. Making the symbol weak for these lower level targets is correct.

vitalybuka added inline comments.Oct 21 2020, 1:14 AM
compiler-rt/lib/sanitizer_common/sanitizer_linux.h
162

How about we remove all references to HAS_ANDROID_THREAD_PROPERTIES_API and assume it's true

and add

void InitializeCommonFlags(CommonFlags *cf) {
  // need to record coverage to generate coverage report.
  cf->coverage |= cf->html_cov_report;
  SetVerbosity(cf->verbosity);
  if (!HAS_ANDROID_THREAD_PROPERTIES_API)
    cf->delect_leaks = false;
}

The patch as is still fails with emulator about 71 tests.
Let's try to cut it in pieces and submit safe one by one.
If you don't have committer access let me know and I can select and land some parts myself.

oontvoo updated this revision to Diff 299688.Oct 21 2020, 7:44 AM
oontvoo marked an inline comment as done.

updated diff

oontvoo added a comment.EditedOct 21 2020, 7:44 AM

The patch as is still fails with emulator about 71 tests.

Were all these 71 tests from check-lsan? I was planning on letting D89615 go in first, then this patch. (Otherwise, this patch would have to be submitted with LSAN-on-Android still disabled.)

Let's try to cut it in pieces and submit safe one by one.

I'll move the test update to a separate patch and submit them there. The rest of this patch, however, should stay together.

Edit: Moved to D89884. PTAL

oontvoo updated this revision to Diff 299696.Oct 21 2020, 8:04 AM

updated diff

The patch as is still fails with emulator about 71 tests.

Were all these 71 tests from check-lsan? I was planning on letting D89615 go in first, then this patch. (Otherwise, this patch would have to be submitted with LSAN-on-Android still disabled.)

yes, it was tls related. you can add D89615 as a parent to avoid confusion

vitalybuka added inline comments.Oct 21 2020, 5:49 PM
compiler-rt/lib/lsan/lsan.cpp
63 ↗(On Diff #299831)

__lsan_default_options can be part of an application and reenabled it again
why not InitializeCommonFlags?

oontvoo added inline comments.Oct 21 2020, 5:52 PM
compiler-rt/lib/lsan/lsan.cpp
63 ↗(On Diff #299831)

__lsan_default_options can be part of an application and reenabled it again

This overrides the commonflag, so we had to set it again.

why not InitializeCommonFlags?

Yes, see InitializeCommonFlags in sanitizer_flags.cpp below.

oontvoo updated this revision to Diff 299836.Oct 21 2020, 5:56 PM
oontvoo marked an inline comment as done.

updated

compiler-rt/lib/lsan/lsan.cpp
63 ↗(On Diff #299831)

PS: nvm - this comes before the common-init.

I lost the track, are we blocked here on something?

I lost the track, are we blocked here on something?

Yes, D89615 should go in first. :-)

vitalybuka accepted this revision.Nov 4 2020, 5:08 PM
vitalybuka added inline comments.
compiler-rt/lib/lsan/lsan_common.cpp
309

why the current dtls from GetThreadRangesLocked does not work here?
probably cleaner to move this logic to where we setup dtls in AsanThread/LsanThread?

compiler-rt/lib/lsan/lsan_common_linux.cpp
110

we don't need this message
it's true for any platform
there are some tests which uses use_globals=0, but normal app should not use use_globals=0

This revision is now accepted and ready to land.Nov 4 2020, 5:08 PM
oontvoo marked an inline comment as done.Nov 4 2020, 5:39 PM
oontvoo added inline comments.
compiler-rt/lib/lsan/lsan_common.cpp
309

why the current dtls from GetThreadRangesLocked does not work here?

The way dtls is currently obtained in GetThreadRangesLocked is via intercepting get_tls_addr and using a bunch of glibc-specific guesses.

probably cleaner to move this logic to where we setup dtls in AsanThread/LsanThread?

Maybe? This doesn't do much other than calling the api function.
Also, I think currently {lsan,asan}Thread tracks dtls with the interceptors, which is completely unnecessary on android since this api lets you query for it after-the-fact.

Probably in an ideal world, we could put the same API in glibc and get rid of this ifdef

vitalybuka added inline comments.Nov 4 2020, 5:55 PM
compiler-rt/lib/lsan/lsan_common.cpp
309

it would be nice to fine a way to remove ifdef in followup patches

I'll land this stapshot soon?

oontvoo marked an inline comment as done.Nov 4 2020, 5:56 PM
oontvoo added inline comments.
compiler-rt/lib/lsan/lsan_common.cpp
309

LGTM. Thanks!

This revision was automatically updated to reflect the committed changes.
dmajor added inline comments.Nov 4 2020, 7:41 PM
compiler-rt/lib/sanitizer_common/sanitizer_flags.cpp
129

The relanding rG484ec6be3066 broke our mac builds (since they don't use sanitizer_linux.h):

error: use of undeclared identifier 'HAS_ANDROID_THREAD_PROPERTIES_API'
oontvoo marked an inline comment as done.Nov 4 2020, 7:43 PM
oontvoo added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_flags.cpp
129

This has been fixed.

dmajor added inline comments.Nov 4 2020, 7:45 PM
compiler-rt/lib/sanitizer_common/sanitizer_flags.cpp
129