How to set up llvm-symbolizer?

Viewed 1898

I was able to push the ASAN related libs located in ANDROID_SDK using the script "asan_device_setup" located inside "Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/7.0.2/bin" from my MacOS.

However, I am unable to get any symbol information for the Address Sanitizer call stack. I pushed the file "llvm-symbolizer" located inside "/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin" to "/system/bin/" on Android device.

When I try to execute "adb shell /system/bin/llvm-symbolizer --help" from terminal, I get some weird error messages. Clearly llvm-symbolizer is not functioning the way it is supposed to.

Consequently, I am seeing this WARNING messages:

==6937==WARNING: external symbolizer didn't start up correctly!
==6937==WARNING: Can't write to symbolizer at fd 56
==6937==WARNING: external symbolizer didn't start up correctly!
==6937==WARNING: Failed to use and restart external symbolizer!

And no symbol information other than the .so+offset with the memory address for the Address Sanitizer related crashes.

I am really not sure where I am going wrong. Is there a way to get the symbol information for ASAN related crashes other than llvm-symbolizer. Please help. Thanks.

1 Answers

I was also trying to find a way to use llvm-symbolizer. Unfortunately without success. However, I found ndk-stack script useful for getting symbols from stack trace. I am running on Android 8.1.

C:\Users\wierzmar\AppData\Local\Android\Sdk\ndk\21.0.6113669>ndk-stack.cmd -sym <my_project_path>\app\build\intermediates\cmake\debug\obj\armeabi-v7a -dump C:\Users\wierzmar\stack.txt
********** Crash dump: **********
Build fingerprint: 'samsung/xcover4ltexx/xcover4lte:8.1.0/M1AJQ/G390FXXU3BRL1:user/release-keys'
Abort message: '=================================================================
#00 0x0001a528 /system/lib/libc.so (abort+63)
#01 0x000389e0 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000)
#02 0x00037754 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000)
#03 0x000a15b8 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000)
#04 0x000a16cc /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000)
#05 0x00044fa0 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000)
#06 0x0009ce00 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000) (__interceptor_free+248)
#07 0x000285e7 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libxxx.so
my_free
armeabi-v7a\../../../../src/main/c/libxxx/src\data.c:6985:9
#08 0x00049db5 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libxxx.so (send_data+2636)
                                                                                                send_data
                                                                                                <my_project_path>\app\.cxx\cmake\debug\armeabi-v7a\../../../../src/main/c/libxxx/src\connection.c:1783:9
#09 0x000470ab /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libxxx.so
client_fun
armeabi-v7a\../../../../src/main/c/libxxx/src\connection.c:960:25
#10 0x00088930 /data/app/com.company.myservice.debug-6r8Uxo3uZSJMR0ESz8bKkg==/lib/arm/libclang_rt.asan-arm-android.so (offset 0x2d000)
#11 0x00048811 /system/lib/libc.so (__pthread_start(void*)+24)
#12 0x0001b369 /system/lib/libc.so (__start_thread+32)
Related