ASan Android x86 crashes on launch

269 views
Skip to first unread message

Sven Dysthe

unread,
Mar 28, 2023, 2:25:50 PM3/28/23
to Chromium-dev
Hi,

I am trying to build ASan Android Chromium and I am encountering an instant crash on opening the apk. Attached logcat of the error. 

In asan.md, the documentation asks to run the command below, however this fails with error attached in error_text.txt. Even after running adb disable-verity and asan_device_setup.sh.

build/android/test_runner.py instrumentation --test-apk ContentShellTest \
    --test_data content:content/test/data/android/device_files -v -v -v \
    --tool=asan --release


Non-ASan chromium runs fine. Has anyone had success building ASan Android Chromium on x86?

Environment: Ubuntu 22.04.2 LTS, Emulator x86 - Pixel 6 Pro API 29 - Android 10.0

Any help is appreciated.
logcat_asan_failure
gn args
error_text

Haiyang Pan

unread,
Mar 28, 2023, 3:33:51 PM3/28/23
to Chromium-dev, Sven Dysthe
Hello,

From the error_text, it appears the test_runner was unable to find the test APK. Can you try calling the following command (Replace the "<out_dir_name>" with your local dir name)?

$ ./out/<out_dir_name>/bin/run_content_shell_test_apk --tool=asan -v <other needed parameters>

Also, if you see other errors related to asan on emulator, feel free to add comments to this bug https://crbug.com/1167287

Sven Dysthe

unread,
Mar 31, 2023, 5:35:48 PM3/31/23
to Chromium-dev, Haiyang Pan, Sven Dysthe
Hi Haiyang Pan,

Firstly, thank you for helping.

I looked for run_content_shell_test_apk, but the APK doesn't exist. FYI, I have built the content_shell_apk with:

autoninja -C out/asan content_shell_apk


I went ahead and went through the link you posted and got pretty far until I ran "./run_base_unittests". I will go through my steps:

1: Booted a fresh emulator using avd.py:
    ~$  tools/android/avd/avd.py start --avd-config tools/android/avd/proto/generic_android30.textpb --emulator-window --writable-system

2: Disabled verity and rebooted the android device (success ):
       adb root 
   adb disable-verity
   adb shell avbctl disable-verification
   adb reboot

3: Executed "asan_device_setup.sh" (success ):
     sudo tools/android/asan/third_party/asan_device_setup.sh --lib /home/sven/chromium/src/third_party/android_ndk/toolchains/llvm/prebuilt/linux-                                x86_64/lib64/clang/12.0.5/lib/linux/libclang_rt.asan-i686-android.so

4: For good measure, I executed the command mentioned on the asan.md doc under section "Building on Android" (success ):
    tools/android/asan/third_party/asan_device_setup.sh --lib third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux

5: According to the linked cbug, base_unit_testtests should run now, HOWEVER this fails (read failed_run_base_unittests.txt ❌):
    ./out/asan/bin/run_base_unittests -v

The asan apk still crashes on start :(


Thank you for following this wall of text!
failed_run_base_unittests.txt

Haiyang Pan

unread,
Apr 3, 2023, 3:34:59 PM4/3/23
to Andre Kempe, xpsven...@gmail.com, Chromium-dev


On Mon, Apr 3, 2023 at 10:50 AM Andre Kempe <Andre...@arm.com> wrote:

Hi Sven,

 

It looks like an error by the runtime linker. In the logs that you have sent you have an error-message

 

- CANNOT LINK EXECUTABLE "/data/local/tmp/md5sum/md5sum_bin": library "libclang_rt.asan-arm-android.so" not found: needed by main executable

 

In https://source.chromium.org/chromium/chromium/src/+/main:tools/android/asan/third_party/asan_device_setup.sh;drc=2f5f360e57e229bd19f8c34bf2c494657b95a252;l=418 we see that the file _should_ be copied to /system/lib/ and /system/lib64/. Could you check this folder, please, if you can find this file there after running asan_device_setup.sh?

 

The question is, is the file missing or is it not accessible.


Given this runs on emulator, I would expect the script to look for the so file in x86 arch (i.e. libclang_rt.asan-i686-android.so), not the arm one (libclang_rt.asan-arm-android.so).

I followed all the steps you listed above and it works fine on my side.

Sven, can you share the GN args you used as well?
 

 

Best Regards,

André

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/540d50b8-46a7-4dbd-b814-0d0674577320n%40chromium.org.

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


--
Best,
Haiyang

Sven Dysthe

unread,
Apr 4, 2023, 12:34:19 AM4/4/23
to Chromium-dev, Haiyang Pan, xpsven...@gmail.com, Chromium-dev, Andre Kempe
-  "Could you check this folder, please, if you can find this file there after running asan_device_setup.sh?"

/system/lib64 does not exist on my generic_android30 device. /system/lib exists, but does *not* contain "libclang_rt.asan-arm-android.so". /system/lib instead contains libclang_rt.asan-i686-android.so  and libclang_rt.ubsan_standalone-i686-android.so. Furthermore, /data/local/tmp/md5sum/md5sum_bin does exist.

Here are my gn args:
    target_os = "android"
    target_cpu = "x86"
    is_asan = true
    is_debug = false

Thanks.
device_about.png

Andre Kempe

unread,
Apr 4, 2023, 1:49:02 PM4/4/23
to xpsven...@gmail.com, Chromium-dev, Haiyang Pan

Hi Sven,

 

It looks like an error by the runtime linker. In the logs that you have sent you have an error-message

 

- CANNOT LINK EXECUTABLE "/data/local/tmp/md5sum/md5sum_bin": library "libclang_rt.asan-arm-android.so" not found: needed by main executable

 

In https://source.chromium.org/chromium/chromium/src/+/main:tools/android/asan/third_party/asan_device_setup.sh;drc=2f5f360e57e229bd19f8c34bf2c494657b95a252;l=418 we see that the file _should_ be copied to /system/lib/ and /system/lib64/. Could you check this folder, please, if you can find this file there after running asan_device_setup.sh?

 

The question is, is the file missing or is it not accessible.

 

Best Regards,

André

 

 

From: chromi...@chromium.org <chromi...@chromium.org> On Behalf Of Sven Dysthe
Sent: Friday, March 31, 2023 10:36 PM
To: Chromium-dev <chromi...@chromium.org>
Cc: Haiyang Pan <hy...@google.com>; Sven Dysthe <xpsven...@gmail.com>
Subject: [chromium-dev] Re: ASan Android x86 crashes on launch

 

Hi Haiyang Pan,

--

--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/540d50b8-46a7-4dbd-b814-0d0674577320n%40chromium.org.

Haiyang Pan

unread,
Apr 4, 2023, 2:08:36 PM4/4/23
to Sven Dysthe, Chromium-dev, Andre Kempe
Thanks for sharing the gn args.

I tried it locally but could not reproduce the same issue. The test script was able to load the so file and execute the tests.

Can you give it another try on your side? I think you can skip step 3 since it is the same as step 4.

--
Best,
Haiyang

Sven Dysthe

unread,
Apr 6, 2023, 2:12:28 PM4/6/23
to Chromium-dev, Haiyang Pan, Chromium-dev, Andre Kempe, Sven Dysthe
I will try soon and post my results. Thanks. 👍
Reply all
Reply to author
Forward
0 new messages