Skip to content

Failing Vulkan tests on Mali GPUs due to pthread_mutex_lock called on destroyed mutex #2833

Closed

Description

@antiagainst

On Samsung S20 with Mali GPUs running build QP1A.190711.020.G980FXXU3ATG4 (adb shell getprop ro.build.display.id), Android fortify discovered an issue:

FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7c490ca4f0)

This can be reproduced by lots of tests, for example,

ctest --output-on-failure -R "vulkan_success" 

Crash dump:

********** Crash dump: **********
Build fingerprint: 'samsung/x1sxx/x1s:10/QP1A.190711.020/G980FXXU3ATG4:user/release-keys'
Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7f37eb74f0)'
#00 0x0000000000083134 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 8506c6089129511bb62873663f6b4533)
#01 0x00000000000e3eb4 /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+116) (BuildId: 8506c6089129511bb62873663f6b4533)
#02 0x00000000000e35a4 /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+52) (BuildId: 8506c6089129511bb62873663f6b4533)
#03 0x00000000000e3404 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_lock+164) (BuildId: 8506c6089129511bb62873663f6b4533)
#04 0x000000000254c150 /vendor/lib64/egl/libGLES_mali.so (BuildId: facf542cb434ba7e8f2c4509706135c8)
#05 0x000000000254aff4 /vendor/lib64/egl/libGLES_mali.so (BuildId: facf542cb434ba7e8f2c4509706135c8)
#06 0x0000000000cf538c /vendor/lib64/egl/libGLES_mali.so (BuildId: facf542cb434ba7e8f2c4509706135c8)
#07 0x00000000000e56e0 /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+212) (BuildId: 8506c6089129511bb62873663f6b4533)
#08 0x0000000000051074 /apex/com.android.runtime/bin/linker64 (__dl__ZN6soinfo16call_destructorsEv+404) (BuildId: 2c4ecc7055fa0de22e6e642dc9e65e57)
#09 0x000000000003bb94 /apex/com.android.runtime/bin/linker64 (__dl__ZL13soinfo_unloadP6soinfo+1060) (BuildId: 2c4ecc7055fa0de22e6e642dc9e65e57)
#10 0x000000000003d50c /apex/com.android.runtime/bin/linker64 (__dl__Z10do_dlclosePv+120) (BuildId: 2c4ecc7055fa0de22e6e642dc9e65e57)
#11 0x000000000003839c /apex/com.android.runtime/bin/linker64 (__loader_dlclose+32) (BuildId: 2c4ecc7055fa0de22e6e642dc9e65e57)
#12 0x000000000000108c /apex/com.android.runtime/lib64/bionic/libdl.so (dlclose+8) (BuildId: ee5a54c32874d345e4d2f02a4cbace8a)
#13 0x00000000003e5fe8 /data/local/tmp/iree/modules/check/test/check_vulkan-spirv_vulkan_success.mlir/iree-check-module
iree::DynamicLibraryPosix::~DynamicLibraryPosix()
??:0:0
#14 0x00000000003e6038 /data/local/tmp/iree/modules/check/test/check_vulkan-spirv_vulkan_success.mlir/iree-check-module
iree::DynamicLibraryPosix::~DynamicLibraryPosix()
??:0:0

It seems an error occurs inside libGLES_mali.so when we try to dlclose it.

Activity

  1. antiagainst commented on Aug 8, 2020

    @antiagainst
    MemberAuthor

    I feel this is gonna to be a nasty bug to figure out. The stack trace involves the GPU driver in the middle so that obscures stuff. It sort of resembles #2659, where we also see failures raising from the GPU driver. Another thing that is common between these two cases is that they are both monolithic drivers. The Mali driver is essentially for both OpenGL, OpenCL, and Vulkan. NVIDIA's GPU driver is containing both OpenGL and Vulkan.. In #2659, we can see functions like eglReleaseThread gotten involved in the stack trace, but eglReleaseThread is for OpenGL. The error here happens in __cxa_finalize, which is deinitializing the shared libary itself. I'm wondering whether it's also OpenGL global state stuff getting involved here too..

  2. antiagainst commented on Aug 8, 2020

    @antiagainst
    MemberAuthor

    Trying to get a simpler test case to repro this. Reducing success.mlir, actually only keeping the add function suffices to trigger it:

    https://github.com/google/iree/blob/4a445bb4045ee3b29a61de8d8893d9b13359d395/iree/modules/check/test/success.mlir#L56-L62

    What's more interesting is that commenting out the check.expect_eq line then it will pass.

  3. antiagainst commented on Aug 8, 2020

    @antiagainst
    MemberAuthor

    A temporary workaround we can have for this is to not dlclose on Android.. It's a bit ugly, but it avoids us to pull Mali GPUs off the CI completely. Really don't want to accumulate other regressions due to that. :( Shared libraries are managed by OS and refcounted anyway; it's unlikely that the GPU .so will be unloaded from the memory completely given there are many users. And we are closing the library almost at program exiting time.

  4. added
    platform/android 🤖
    hal/vulkan
    bug 🐞
    on Aug 8, 2020
  5. self-assigned this
    on Aug 11, 2020
  6. hanhanW commented on Aug 12, 2020

    @hanhanW
    Contributor

    I can't reproduce this on my Samsung S10. Android build QP1A.190711.020.G973FXXS7CTG1

    Follow instructions in the doc to build IREE on Android
    $ ctest -V -R "vulkan_success"
    

    @antiagainst Sorry that I don't remember, should I upgrade the Android to the latest version? I remember that there is an issue there?

  7. antiagainst commented on Aug 12, 2020

    @antiagainst
    MemberAuthor

    Yes you'll need to update to QP1A.190711.020.G980FXXU3ATG4 (with July 1, 2020 security patch). But BEFORE doing that, please copy /vendor/lib64/egl/libGLES_mali.so to your desktop/laptop for backup so that later you can use it under /data/local/tmp to bypass the issue if needed.

  8. hanhanW commented on Aug 12, 2020

    @hanhanW
    Contributor

    Hmm, my Samsung S10 thinks that it's already upgraded to the latest. It's also the July 1, 2020 security patch. It seems that this bug is not reproducible on Samsung S10?

    I also replace the libvulkan.so with /vendor/lib64/hw/vulkan.*.so, and it's still passing.

  9. antiagainst commented on Aug 12, 2020

    @antiagainst
    MemberAuthor

    Thanks Hanhan. This might be a Mali G77 (which is what S20 has) specific issue then. :(

  10. antiagainst commented on Aug 12, 2020

    @antiagainst
    MemberAuthor

    libGLES_mali.so from S20 at QP1A.190711.020.G980FXXU1ATCT works. Given this only shows up on Mali G77 with a specific Android build, I'll de-prioritize this and copy an older driver to temporary workaround and make sure we don't accumulate other regressions.

  11. antiagainst commented on Oct 26, 2020

    @antiagainst
    MemberAuthor

    I'm not seeing this issue anymore with the most recent build. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐞hal/vulkanplatform/android 🤖

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions