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

QAndroidApplication::runOnAndroidMainThread() UB when timeout is set

    XMLWordPrintable

Details

    • Android
    • 26ea6157e (dev), 500e16198 (dev), 3642d5680 (dev), c04960134 (dev), f9e9dd19c (6.5), 55bef5d26 (6.5), db7d301f9 (6.5), cea3c2ce0 (6.5), a3d8512fe (6.4), 9f0a75d26 (6.4), 991b5dfe8 (6.4), 845aa0378 (tqtc/lts-6.2), 6fdccc6df (tqtc/lts-6.2), a6ea94cc3 (6.4)
    • Foundation Sprint 72

    Description

      The QAndroidApplication::runOnAndroidMainThread() function creates a task on QThreadPool::globalInstance()¹ to wait for a timeout and cancel a QFuture. If does so by passing a lambda to QtConcurrent::run()² that captures the future, a local variable, by reference. This is UB when the lambda is ever executed, because the local stack variable's lifetime will have ended.

      I'm not sure how to fix it, therefore this ticket.

      ¹ thereby blocking a full worker thread in QThreadPool::globalInstance() from doing any productive work, possibly delaying actual work being done and, in the last consequence, causing a (timed) deadlock, and False Positive timeouts because work that would unblock the waiter can't be performed

      ² Isn't QtConcurrent dependent on QtCore, and not the other way around?

      Attachments

        For Gerrit Dashboard: QTBUG-109586
        # Subject Branch Project Status CR V

        Activity

          People

            mmutz Marc Mutz
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes