Skip to content

Commit

Permalink
Add workaround #988 the default wrap.sh.
Browse files Browse the repository at this point in the history
This can't help users of the static STL, but it does help those using
the shared STL.

Also clean up by merging these into a single wrap.sh. There should
never be more than one ASan library in the directory, so we can just
use a wildcard.

Test: https://github.com/DanAlbert/asan-wrap-sh-exceptions-crash-repro
Bug: android/ndk#988
Change-Id: I890ba18faaebcdafe61f2800cc062ec7b5d9502e
  • Loading branch information
DanAlbert committed Jul 9, 2019
1 parent 0178faf commit aa7f843
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 25 deletions.
3 changes: 1 addition & 2 deletions build/core/sanitizers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ include $(BUILD_SYSTEM)/install_sanitizer.mk
# default ASAN wrap.sh for them.
ifneq (,$(filter address,$(NDK_SANITIZERS)))
ifeq ($(NDK_NO_USER_WRAP_SH),true)
NDK_APP_WRAP_SH_$(TARGET_ARCH_ABI) := \
$(NDK_ROOT)/wrap.sh/asan.$(TARGET_ARCH_ABI).sh
NDK_APP_WRAP_SH_$(TARGET_ARCH_ABI) := $(NDK_ROOT)/wrap.sh/asan.sh
endif
endif
6 changes: 3 additions & 3 deletions docs/BuildSystemMaintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ than Valgrind (roughly 50% performance compared to an unsanitized application).
To use ASan, pass `-fsanitize=address` when both compiling and linking. The
sanitizer runtime libraries are installed to
`<NDK>/toolchains/llvm/prebuilt/<host-tag>/lib64/clang/<clang-version>/lib/linux`.
The library is named `libclang_rt.asan-<arch>-android.so`. This library must be
included in the APK. A [wrap.sh] file must also be included in the APK. Premade
wrap.sh files for ASan are installed to `<NDK>/wrap.sh`.
The library is named `libclang_rt.asan-<arch>-android.so`. This library must be
included in the APK. A [wrap.sh] file must also be included in the APK. A
premade wrap.sh file for ASan is installed to `<NDK>/wrap.sh`.

Note: wrap.sh is only available for [debuggable] APKs running on Android Oreo
(API 26) or higher. ASan can still be used devices prior to Oreo but at least
Expand Down
5 changes: 0 additions & 5 deletions wrap.sh/asan.arm64-v8a.sh

This file was deleted.

5 changes: 0 additions & 5 deletions wrap.sh/asan.armeabi-v7a.sh

This file was deleted.

11 changes: 11 additions & 0 deletions wrap.sh/asan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/system/bin/sh
HERE="$(cd "$(dirname "$0")" && pwd)"
export ASAN_OPTIONS=log_to_syslog=false,allow_user_segv_handler=1
ASAN_LIB=$(ls $HERE/libclang_rt.asan-*-android.so)
if [ -f "$HERE/libc++_shared.so" ]; then
# Workaround for https://github.com/android-ndk/ndk/issues/988.
export LD_PRELOAD="$ASAN_LIB $HERE/libc++_shared.so"
else
export LD_PRELOAD="$ASAN_LIB"
fi
"$@"
5 changes: 0 additions & 5 deletions wrap.sh/asan.x86.sh

This file was deleted.

5 changes: 0 additions & 5 deletions wrap.sh/asan.x86_64.sh

This file was deleted.

0 comments on commit aa7f843

Please sign in to comment.