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

Qt concurrent blockingFilter() runs in random thread

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • None
    • 6.0.0
    • Core: Threads
    • None
    • 20
    • Qt6_Foundation_ Sprint 10

    Description

      It looks like blockingFilter() invokes a working function from:

      • a newly created thread from a global thread pool
      • or directly from main thread

      In order to test it I set maxThreadCount for the global QThreadPool to 1 and run blockingFilter method. The test case is here:

      https://codereview.qt-project.org/c/qt/qtbase/+/298910

      The output is:

      PASS : tst_QtConcurrentFilter::initTestCase()
      QDEBUG : tst_QtConcurrentFilter::filterThreadPool() Main thread QThread(0x555f03411e30)
      QDEBUG : tst_QtConcurrentFilter::filterThreadPool() current working thread: QThread(0x555f03411e30)
      QDEBUG : tst_QtConcurrentFilter::filterThreadPool() current working thread: QThread(0x555f034148d0, name = "Thread (pooled)")
      QDEBUG : tst_QtConcurrentFilter::filterThreadPool() current working thread: QThread(0x555f03411e30)
      QDEBUG : tst_QtConcurrentFilter::filterThreadPool() current working thread: QThread(0x555f034148d0, name = "Thread (pooled)")
      FAIL! : tst_QtConcurrentFilter::filterThreadPool() Compared values are not the same
      Actual (workingThreads.size()): 2
      Expected (1) : 1
      Loc: [/home/jarek/dev/qt-dev/qtbase/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp(127)]
      FAIL! : tst_QtConcurrentFilter::filterThreadPool() failed one line above on functor
      Loc: [/home/jarek/dev/qt-dev/qtbase/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp(143)]
      PASS : tst_QtConcurrentFilter::cleanupTestCase()
      Totals: 2 passed, 2 failed, 0 skipped, 0 blacklisted, 8123ms

      The call stack when working function is called directly from the main thread:

      1 KeepOddIntegers::operator() tst_qtconcurrentfilter.cpp 106 0x555555585f53
      2 std::__invoke_impl<bool, KeepOddIntegers&, int const&> invoke.h 60 0x5555555bb967
      3 std::__invoke<KeepOddIntegers&, int const&> invoke.h 96 0x5555555b9076
      4 std::invoke<KeepOddIntegers&, int const&> functional 81 0x5555555b3149
      5 QtConcurrent::FilterKernel<QVector<int>, KeepOddIntegers, QtPrivate::PushBackWrapper>::runIterations qtconcurrentfilterkernel.h 122 0x5555555ab56d
      6 QtConcurrent::IterateKernel<int const *, void>::forThreadFunction qtconcurrentiteratekernel.h 231 0x5555555b2e6c
      7 QtConcurrent::IterateKernel<int const *, void>::threadFunction qtconcurrentiteratekernel.h 193 0x5555555ab2ba
      8 QtConcurrent::ThreadEngineBase::startBlocking qtconcurrentthreadengine.cpp 189 0x7ffff7949a6c
      9 QtConcurrent::ThreadEngine<void>::startBlocking qtconcurrentthreadengine.h 153 0x555555586420
      10 QtConcurrent::ThreadEngineStarter<void>::startBlocking qtconcurrentthreadengine.h 256 0x555555585c45
      11 QtConcurrent::blockingFilter<QVector<int>, KeepOddIntegers> qtconcurrentfilter.h 197 0x55555558f40f
      12 testFilterGlobalPool<int, int, KeepOddIntegers> tst_qtconcurrentfilter.cpp 123 0x555555587099
      13 tst_QtConcurrentFilter::filterThreadPool tst_qtconcurrentfilter.cpp 142 0x555555566ce4
      14 tst_QtConcurrentFilter::qt_static_metacall tst_qtconcurrentfilter.moc 108 0x55555556ab61
      15 QMetaMethod::invoke qmetaobject.cpp 2290 0x7ffff72844b3
      16 QMetaMethod::invoke qmetaobject.h 120 0x7ffff7b727d1
      17 QTest::TestMethods::invokeTestOnData qtestcase.cpp 938 0x7ffff7b6a86f
      18 QTest::TestMethods::invokeTest qtestcase.cpp 1166 0x7ffff7b6b43c
      19 QTest::TestMethods::invokeTests qtestcase.cpp 1507 0x7ffff7b6c7ee
      20 QTest::qRun qtestcase.cpp 1934 0x7ffff7b6d091
      ... <More>

      The call stack when it's called from a thread comming from a thread pool:

      1 KeepOddIntegers::operator() tst_qtconcurrentfilter.cpp 106 0x555555585f53
      2 std::__invoke_impl<bool, KeepOddIntegers&, int const&> invoke.h 60 0x5555555bb967
      3 std::__invoke<KeepOddIntegers&, int const&> invoke.h 96 0x5555555b9076
      4 std::invoke<KeepOddIntegers&, int const&> functional 81 0x5555555b3149
      5 QtConcurrent::FilterKernel<QVector<int>, KeepOddIntegers, QtPrivate::PushBackWrapper>::runIterations qtconcurrentfilterkernel.h 122 0x5555555ab56d
      6 QtConcurrent::IterateKernel<int const *, void>::forThreadFunction qtconcurrentiteratekernel.h 231 0x5555555b2e6c
      7 QtConcurrent::IterateKernel<int const *, void>::threadFunction qtconcurrentiteratekernel.h 193 0x5555555ab2ba
      8 QtConcurrent::ThreadEngineBase::run qtconcurrentthreadengine.cpp 302 0x7ffff7949e5e
      9 QThreadPoolThread::run qthreadpool.cpp 98 0x7ffff6fd448a
      10 QThreadPrivate::start qthread_unix.cpp 342 0x7ffff6fcc886
      11 start_thread pthread_create.c 463 0x7ffff63096db
      12 clone clone.S 95 0x7ffff664288f

      Attachments

        Issue Links

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

          Activity

            People

              jkobus Jarek Kobus
              jkobus Jarek Kobus
              Maurice Kalinowski Maurice Kalinowski
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes