Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85449

Crashes at the destructors of std::thread and std::mutex.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P1: Critical
    • 5.15, 6.2
    • 5.12.8, 5.13.2, 5.14.2, 5.15.0
    • Core: Threads
    • Huawei FLA-AL20, Android 9
      Huawei nova 3i (HWINE), 3840MB RAM, Android 9
      Huawei FIG-LX1 (HWFIG-H), 2816MB RAM, Android 9
      Huawei HUAWEI Y9 Prime 2019 (HWSTK-HF), 3840MB RAM, Android 9
      Android 10*
    • Android

    Description

      QT application periodically crashes at the destructors of std::thread and std::mutex when it is closed with 'back button' on the device with the following call stack: 

       #00 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)
       #01 /system/lib64/libc++.so (abort_message+232)
       #02 /system/lib64/libc++.so (demangling_terminate_handler()+44)
       #03 /system/lib64/libc++.so (std::__terminate(void ())+12)
       #04 /system/lib64/libc++.so (std::terminate()+52)
       #05 /system/lib64/libc++.so (std::__1::thread::~thread()+20)
       #06 /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+212)
       #07 /apex/com.android.runtime/lib64/bionic/libc.so (exit+24)
       #08 /data/app/com.domain.myapp-Rs_sm5VrLR1Jj8QW6oYByA==/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so
       
      

      or

       #00 /apex/com.android.runtime/lib64/bionic/libc.so (abort+176)
       #01 /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+116)
       #02 /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+52)
       #03 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_destroy+148)
       #04 /system/lib64/libc++.so (std::__1::mutex::~mutex()+8)
       #05 /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+212)
       #06 /apex/com.android.runtime/lib64/bionic/libc.so (exit+24)
       #07 /data/app/com.domain.myapp-hLEaSANDEatnCiV7f2wbeg==/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so
        

      and there are some other crashes, see [my blog post|https://developernote.com/2020/04/qt-app-crashes-at-the-destructor-of-std-thread-on-android-10/] for more information.

      I discussed this on [stackoverflow.com|https://stackoverflow.com/questions/61321845/qt-app-crashes-at-the-destructor-of-stdthread-on-android-10-devices] and another developer confirmed that he has the same crashes in his app and found a workaround.

      The workaround is to call System.exit(0) in Java code when 'back button' is pressed on the device (to prevent C++ deinitialization)

      These crashes are hard to reproduce, so theoretically there can be some kind of a data race.

      QT: 5.14 and 5.15

      Android: 10 (lesser 9, but not previous versions)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              taipan BogDan Vatra
              dmitriano Dmitry Efimov
              Votes:
              29 Vote for this issue
              Watchers:
              37 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: