android / ndk

The Android Native Development Kit
2.01k stars 257 forks source link

[BUG]After upgrading NDK from r21e to r25c, the flutter demo with the ASAN Native plugin enabled cannot be started #2077

Closed JerryWang-0 closed 1 month ago

JerryWang-0 commented 1 month ago

Description

We have a Native so library, and sometimes we need to enable ASAN to locate memory problems. The Native so library will be integrated into the flutter demo as a flutter plugin. We recently upgraded NDK from r21e to r25c. If ASAN is enabled, the demo will not start. We tried upgrading ndk to r26b, and the problem still exists

test case: https://github.com/JerryWang-0/TestAsan device: OnePlus9, Android14

logcat backtrace: Process name is /system/bin/app_process64 -Xcompiler-option --generate-mini-debug-info /system/bin --application --nice-name=com.example.test_library_example com.android.internal.os.WrapperInit 74 34 android.app.ActivityThread seq=3577, not key_process keyProcess: 0


Build fingerprint: 'OnePlus/OnePlus9_CH/OnePlus9:14/UKQ1.230924.001/R.1695bcd-5150_1:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: 2024-09-26 14:22:21.005211418+0800 Process uptime: 1s Cmdline: /system/bin/app_process64 -Xcompiler-option --generate-mini-debug-info /system/bin --application --nice-name=com.example.test_library_example com.android.internal.os.WrapperInit 74 34 android.app.ActivityThread seq=3577 pid: 12072, tid: 12072, name: app_process64 >>> /system/bin/app_process64 <<< uid: 10586 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000 Cause: null pointer dereference x0 000000704b7fc508 x1 0000007fdb33ed08 x2 000000704b87321c x3 0000000000000000 x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 0000000000000000 x8 0000000000000000 x9 0000000000000000 x10 0000000000000001 x11 000000000000003b x12 0000007059cf98b9 x13 0000000000000000 x14 0000000000000000 x15 0000000000000000 x16 000000704b7f7768 x17 000000704755ba50 x18 000000705a6c2000 x19 000000704b7fc508 x20 000000704b87321c x21 0000007fdb33ed08 x22 0000007059cff000 x23 0000000000000001 x24 000000705aec6000 x25 000000705aec61e8 x26 0000000000000006 x27 000000705aec6160 x28 0000000000000000 x29 0000007fdb33ecc0 lr 000000704755ba90 sp 0000007fdb33ecb0 pc 0000000000000000 pst 0000000000001000 19 total frames backtrace:

00 pc 0000000000000000

  #01 pc 000000000008ba8c  /data/app/~~AZpEgsrVIF6io_W2rC15GQ==/com.example.test_library_example-GIDuhYpFGeLq_Fr4t-2aTA==/lib/arm64/libclang_rt.asan-aarch64-android.so (__interceptor_pthread_mutex_lock+60) (BuildId: d39265be9efeee419e565f66dd253078e6302c36)
  #02 pc 00000000000a09d0  /apex/com.android.art/lib64/libc++.so (std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*))+44) (BuildId: 3e4354695cf2fa8a0e4865a8855383a4)
  #03 pc 0000000000002d54  /apex/com.android.art/lib64/libsigchain.so (sigprocmask64+100) (BuildId: 0eb1ce8eec78535f631bcc5607023e38)
  #04 pc 000000000009cda4  /apex/com.android.runtime/lib64/bionic/libc.so (abort+60) (BuildId: d1a98b526f2f94260a53c3055979a4f6)
  #05 pc 00000000000542f8  /data/app/~~AZpEgsrVIF6io_W2rC15GQ==/com.example.test_library_example-GIDuhYpFGeLq_Fr4t-2aTA==/lib/arm64/libclang_rt.asan-aarch64-android.so (BuildId: d39265be9efeee419e565f66dd253078e6302c36)
  #06 pc 0000000000052cf4  /data/app/~~AZpEgsrVIF6io_W2rC15GQ==/com.example.test_library_example-GIDuhYpFGeLq_Fr4t-2aTA==/lib/arm64/libclang_rt.asan-aarch64-android.so (BuildId: d39265be9efeee419e565f66dd253078e6302c36)
  #07 pc 0000000000049cd4  /data/app/~~AZpEgsrVIF6io_W2rC15GQ==/com.example.test_library_example-GIDuhYpFGeLq_Fr4t-2aTA==/lib/arm64/libclang_rt.asan-aarch64-android.so (BuildId: d39265be9efeee419e565f66dd253078e6302c36)
  #08 pc 00000000000bb3a8  /data/app/~~AZpEgsrVIF6io_W2rC15GQ==/com.example.test_library_example-GIDuhYpFGeLq_Fr4t-2aTA==/lib/arm64/libclang_rt.asan-aarch64-android.so (BuildId: d39265be9efeee419e565f66dd253078e6302c36)
  #09 pc 0000000000074c04  /data/app/~~AZpEgsrVIF6io_W2rC15GQ==/com.example.test_library_example-GIDuhYpFGeLq_Fr4t-2aTA==/lib/arm64/libclang_rt.asan-aarch64-android.so (__interceptor_strcmp+776) (BuildId: d39265be9efeee419e565f66dd253078e6302c36)
  #10 pc 000000000009890c  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init_vdso(libc_globals*)+404) (BuildId: d1a98b526f2f94260a53c3055979a4f6)
  #11 pc 00000000000a7658  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init_globals()+96) (BuildId: d1a98b526f2f94260a53c3055979a4f6)
  #12 pc 00000000000954c8  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_preinit_impl()+44) (BuildId: d1a98b526f2f94260a53c3055979a4f6)
  #13 pc 00000000000636e0  /apex/com.android.runtime/bin/linker64 (__dl__ZN6soinfo17call_constructorsEv+752) (BuildId: 580b54328d39d2c58499eb3a2483f03f)
  #14 pc 0000000000063488  /apex/com.android.runtime/bin/linker64 (__dl__ZN6soinfo17call_constructorsEv+152) (BuildId: 580b54328d39d2c58499eb3a2483f03f)
  #15 pc 0000000000063488  /apex/com.android.runtime/bin/linker64 (__dl__ZN6soinfo17call_constructorsEv+152) (BuildId: 580b54328d39d2c58499eb3a2483f03f)
  #16 pc 00000000000d5900  /apex/com.android.runtime/bin/linker64 (__dl__ZL29__linker_init_post_relocationR19KernelArgumentBlockR6soinfo+4200) (BuildId: 580b54328d39d2c58499eb3a2483f03f)
  #17 pc 00000000000d4840  /apex/com.android.runtime/bin/linker64 (__dl___linker_init+832) (BuildId: 580b54328d39d2c58499eb3a2483f03f)
  #18 pc 00000000000662f8  /apex/com.android.runtime/bin/linker64 (__dl__start+8) (BuildId: 580b54328d39d2c58499eb3a2483f03f)

Affected versions

r26

Canary version

No response

Host OS

Mac

Host OS version

macOS14.5

Affected ABIs

arm64-v8a

Build system

ndk-build

Other build system

No response

minSdkVersion

21

Device API level

No response

enh-google commented 1 month ago

r27 is current, not r26 ... but asan isn't really supported anymore anyway. you'll want to use hwasan. it's better in every way: https://developer.android.com/ndk/guides/hwasan

JerryWang-0 commented 1 month ago

@enh-google It seems that this problem started to occur in r25 and also exists in r27. Depending on the Android system version, we may use hwasan or asan. hwasan is only supported starting from Android 10.