Android Meson build regression: hardware/system information apps crash on Raspberry Pi 4
I wanted to report a regression on Mesa Android build related to switching to the Meson build system in Mesa 21.2.
This issue can be reproduced on GloDroid and LineageOS builds for the Pi 4. Launching any(?) system/hardware information application will shortly crash with following log:
10-08 11:30:04.479 3072 3072 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-08 11:30:04.479 3072 3072 F DEBUG : Build fingerprint: 'RaspberryPI/rpi4/rpi4:12/SP1A.210812.016/eng.roman.20211005.170921:userdebug/test-keys'
10-08 11:30:04.479 3072 3072 F DEBUG : Revision: '1.0'
10-08 11:30:04.480 3072 3072 F DEBUG : ABI: 'arm64'
10-08 11:30:04.480 3072 3072 F DEBUG : Timestamp: 2021-10-08 11:30:03.001342134+0000
10-08 11:30:04.480 3072 3072 F DEBUG : Process uptime: 5s
10-08 11:30:04.481 3072 3072 F DEBUG : Cmdline: com.finalwire.aida64
10-08 11:30:04.481 3072 3072 F DEBUG : pid: 2915, tid: 3043, name: GLThread 83 >>> com.finalwire.aida64 <<<
10-08 11:30:04.481 3072 3072 F DEBUG : uid: 10075
10-08 11:30:04.481 3072 3072 F DEBUG : tagged_addr_ctrl: 0000000000000001
10-08 11:30:04.482 3072 3072 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
10-08 11:30:04.482 3072 3072 F DEBUG : Abort message: 'Scudo ERROR: invalid chunk state when deallocating address 0x200007cf39e3110
10-08 11:30:04.482 3072 3072 F DEBUG : '
10-08 11:30:04.482 3072 3072 F DEBUG : x0 0000000000000000 x1 0000000000000be3 x2 0000000000000006 x3 0000007c058539e0
10-08 11:30:04.483 3072 3072 F DEBUG : x4 0000000000808080 x5 0000000000808080 x6 0000000000808080 x7 8080800000000000
10-08 11:30:04.483 3072 3072 F DEBUG : x8 00000000000000f0 x9 0000007f6eb060b0 x10 ffffff00fffffbdf x11 0000000000000001
10-08 11:30:04.483 3072 3072 F DEBUG : x12 0101010101010101 x13 0000000000000030 x14 0000000000000000 x15 0000000000000070
10-08 11:30:04.484 3072 3072 F DEBUG : x16 0000007f6eba6050 x17 0000007f6eb82700 x18 0000007c047e4000 x19 00000000000000ac
10-08 11:30:04.484 3072 3072 F DEBUG : x20 0000000000000b63 x21 00000000000000b2 x22 0000000000000be3 x23 00000000ffffffff
10-08 11:30:04.484 3072 3072 F DEBUG : x24 0000007c05853cb0 x25 0000007c05853cb0 x26 0000007c05853ff8 x27 000000000010a000
10-08 11:30:04.484 3072 3072 F DEBUG : x28 0000000000108000 x29 0000007c05853a60
10-08 11:30:04.485 3072 3072 F DEBUG : lr 0000007f6eb33efc sp 0000007c058539c0 pc 0000007f6eb33f2c pst 0000000000000000
10-08 11:30:04.485 3072 3072 F DEBUG : backtrace:
10-08 11:30:04.485 3072 3072 F DEBUG : #00 pc 000000000004ff2c /apex/com.android.runtime/lib64/bionic/libc.so (abort+180) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
10-08 11:30:04.486 3072 3072 F DEBUG : #01 pc 0000000000040430 /apex/com.android.runtime/lib64/bionic/libc.so (scudo::die()+8) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
10-08 11:30:04.486 3072 3072 F DEBUG : #02 pc 0000000000040c08 /apex/com.android.runtime/lib64/bionic/libc.so (scudo::ScopedErrorReport::~ScopedErrorReport()+32) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe57
05dd)
10-08 11:30:04.486 3072 3072 F DEBUG : #03 pc 0000000000040e44 /apex/com.android.runtime/lib64/bionic/libc.so (scudo::reportInvalidChunkState(scudo::AllocatorAction, void*)+76) (BuildId: ac3d0baaacdc7
c6cdebcc4f2fe5705dd)
10-08 11:30:04.487 3072 3072 F DEBUG : #04 pc 0000000000042464 /apex/com.android.runtime/lib64/bionic/libc.so (scudo::Allocator<scudo::AndroidConfig, &(scudo_malloc_postinit)>::deallocate(void*, scudo
::Chunk::Origin, unsigned long, unsigned long)+308) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
10-08 11:30:04.487 3072 3072 F DEBUG : #05 pc 000000000001844c /vendor/lib64/egl/libEGL_mesa.so (BuildId: d9ef3557a41fde917808c1f16247ef3d)
10-08 11:30:04.487 3072 3072 F DEBUG : #06 pc 000000000001245c /vendor/lib64/egl/libEGL_mesa.so (eglReleaseThread+20) (BuildId: d9ef3557a41fde917808c1f16247ef3d)
10-08 11:30:04.487 3072 3072 F DEBUG : #07 pc 00000000000204ac /system/lib64/libEGL.so (android::eglReleaseThreadImpl()+36) (BuildId: e162bdb7137f5a71946fd1b9cf5c1810)
10-08 11:30:04.488 3072 3072 F DEBUG : #08 pc 0000000000014080 /system/lib64/libEGL.so (android::egl_tls_t::destructTLSData(void*)+32) (BuildId: e162bdb7137f5a71946fd1b9cf5c1810)
10-08 11:30:04.488 3072 3072 F DEBUG : #09 pc 00000000000b3e24 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_key_clean_all()+132) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
10-08 11:30:04.488 3072 3072 F DEBUG : #10 pc 00000000000b35b0 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_exit+72) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
10-08 11:30:04.489 3072 3072 F DEBUG : #11 pc 00000000000b343c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+268) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
10-08 11:30:04.489 3072 3072 F DEBUG : #12 pc 00000000000517c8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: ac3d0baaacdc7c6cdebcc4f2fe5705dd)
This can be reproduced with AIDA64 (https://www.apkmirror.com/apk/finalwire-ltd/aida64/) and Droid Hardware Info (https://www.apkmirror.com/apk/inkwired/droid-hardware-info/) at least.
I've found that this is clearly something related to the Mesa Meson build. This issue is not present on Mesa 21.1 that still uses Android.mk to build. I've ported the Meson build patches to Mesa 21.1 and I can reproduce this with Mesa 21.1 as well after building it with Meson.
As discussed with @roman.stratiienko at https://github.com/GloDroid/glodroid_manifest/issues/160 disabling TLS for the Android build fixes this issue.