Symbolized ASan output on Android

If running ASan on the host architecture, we can symbolize output with:

    export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
    ./myInstrumentedProgram

but on Android symbolizing is more complex. The bash script below is
a "hello world" for symbolizing ASan output on Android. Is there a
simpler way to do this?

    # Execute the test and save its output
     adb push myInstrumentedProgram /data/data/
     adb shell "LD_PRELOAD=/data/data/libclang_rt.asan-arm-android.so
/data/data/myInstrumentedProgram" | tee out/err.txt

     # Pull runtime dependencies so we can demangle the output
     adb pull /system/lib/libc.so out/
     adb pull /data/data/libclang_rt.asan-arm-android.so out/

    # Fix-up the output and demangle
    sed 's/\/data\/data/out/g' out/err.txt | \
    sed 's/\/system\/lib/out/g' | \
    $LLVM_DIR/utils/sanitizers/asan_symbolize.py --demangle

Is it possible to embed llvm-symbolizer into the ASan runtime?

Thanks,
Greg

If running ASan on the host architecture, we can symbolize output with:

    export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
    ./myInstrumentedProgram

but on Android symbolizing is more complex. The bash script below is
a "hello world" for symbolizing ASan output on Android. Is there a
simpler way to do this?

    # Execute the test and save its output
     adb push myInstrumentedProgram /data/data/
     adb shell "LD_PRELOAD=/data/data/libclang_rt.asan-arm-android.so
/data/data/myInstrumentedProgram" | tee out/err.txt

     # Pull runtime dependencies so we can demangle the output
     adb pull /system/lib/libc.so out/
     adb pull /data/data/libclang_rt.asan-arm-android.so out/

    # Fix-up the output and demangle
    sed 's/\/data\/data/out/g' out/err.txt | \
    sed 's/\/system\/lib/out/g' | \
    $LLVM_DIR/utils/sanitizers/asan_symbolize.py --demangle

Is it possible to embed llvm-symbolizer into the ASan runtime?

We have a working solution for using in-process symbolization in sanitizer
tools
(for Linux/x86_64), but it's somewhat complicated and is not yet upstreamed.
Once it's in the trunk, it should be possible to port it to Android as well.
Can't give you a very promising estimate, though :frowning:

Thanks for letting me know that this is in the works. This is
something that would make running ASan (and all other sanitizers I
assume) quite a bit more appealing on Android. If there's anything I
can do to help, please let me know. If you'd like to discuss in
person, I'll be at the Developers' Meeting next week.

-Greg

Thanks for letting me know that this is in the works. This is
something that would make running ASan (and all other sanitizers I
assume) quite a bit more appealing on Android.

Not just for Android.
But beware that the symbolization is a heavy thing -- it requires more RAM
and more CPU -- so some our users
have to disable it and symbolize output offline to save resources.
(We still want to have in-process symbolizer upstreamed very much)

If there's anything I
can do to help, please let me know. If you'd like to discuss in
person, I'll be at the Developers' Meeting next week.

Good! See you there.

--kcc