Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBsan support on ARM64 #393

Closed
butterl opened this issue May 11, 2017 · 1 comment
Closed

UBsan support on ARM64 #393

butterl opened this issue May 11, 2017 · 1 comment
Labels

Comments

@butterl
Copy link

butterl commented May 11, 2017

Description

I ‘ve tried modified the android build script in AOSP to build the ubsan related libs

libclang_rt.ubsan_standalone-arm-android.so 
libclang_rt.ubsan_standalone-aarch64-android.so 
libubsan.a

with flags added in Android.mk

LOCAL_CLANG := true
LOCAL_UNDEFINED_SANITIZER := true
LOCAL_SANITIZE:= undefined
LOCAL_CFLAGS += -g -Wall -Werror -std=gnu++11 -Wno-missing-field-initializers -O0 -fsanitize=undefined

And the so have been linked to the test app

butter@desktop:~/code/prebuilts$ ./gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/objdump -x ../out/target/product/generic_arm64/obj/NATIVE_TESTS/gatekeeper-unit-tests_intermediates/gatekeeper-unit-tests | grep NEEDED
NEEDED libclang_rt.ubsan_standalone-aarch64-android.so

So I added a NULL pointer UB demo to a gtest module like below to see if ubsan works:

static uint8_t gtest_UBsan_demo(void)
{
uint8_t test = 32;
uint8_t *undefined = NULL;
if (test)
{
*undefined = test;
}
return 0;
}

Then build and push the test gtest app and libclang_rt.ubsan_standalone-aarch64-android.so to my board but the simulation backtrace got no Ubsan information

backtrace:
00 pc 0000000000069bac /system/lib64/libc.so (tgkill+8)
01 pc 000000000001da48 /system/lib64/libc.so (abort+80)
02 pc 000000000003a878 /data/gatekeeper-unit-tests (_ZL16gtest_UBsan_demov+104)
03 pc 000000000002bf4c /data/gatekeeper-unit-tests (_ZL11make_bufferj+16)
04 pc 000000000002a044 /data/gatekeeper-unit-tests (_ZN54RoundTripTest_EnrollRequestNullEnrolledNullHandle_Test8TestBodyEv+52)
05 pc 00000000000845d0 /data/gatekeeper-unit-tests (_ZN7testing4Test3RunEv+392)
06 pc 000000000008504c /data/gatekeeper-unit-tests (_ZN7testing8TestInfo3RunEv+404)
07 pc 00000000000854f4 /data/gatekeeper-unit-tests (_ZN7testing8TestCase3RunEv+240)
08 pc 000000000008bc80 /data/gatekeeper-unit-tests (_ZN7testing8internal12UnitTestImpl11RunAllTestsEv+1112)
09 pc 000000000008b7f4 /data/gatekeeper-unit-tests (_ZN7testing8UnitTest3RunEv+184)
10 pc 000000000007ee84 /data/gatekeeper-unit-tests (main+64)
11 pc 000000000001b744 /system/lib64/libc.so (__libc_init+88)
12 pc 000000000002935c /data/gatekeeper-unit-tests (do_arm64_start+80)

Am I missing something that UBsan needed to run on the ARM64 board?

@DanAlbert
Copy link
Member

Follow https://source.android.com/source/report-bugs to file a bug for AOSP. This is just for the NDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants