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

QThread internal error while waiting for adopted threads: 87

    XMLWordPrintable

Details

    • Qt 5.2.1 (stable, 17.12.2013) d1f8a5641615eb83bb36b4ada5913531d0da24f1 Qt 4.8.6 (0cc34cf0f4e9b64f3efa21ec57e7e27f4a6d879e )

    Description

      Under Windows I get this message from time to time:

      QThread internal error while waiting for adopted threads: 87

      This message comes from Qt and is printed by qWarning() method. I found where and why this happens.

      This happens in method qt_adopted_thread_watcher_function in files corelib/thread/qthread_win.cpp.

      The reason is that, when size of array qt_adopted_thread_handles is a multiple of MAXIMUM_WAIT_OBJECTS (which is 64), the last call to WaitForMultipleObjects in do-while loop contains count == 0. But this is not allowed according to MSDN and call fails with GetLastError() == ERROR_INVALID_PARAMETER, which is 87. It does no harm to a program, but warnings are annoying.

      I made a test to reproduce the problem. See attached file. 2 fixes are possible:

      Fix 1:
      int loops = (handlesCopy.count() / MAXIMUM_WAIT_OBJECTS), offset, count;
      if ( (handlesCopy.count() % MAXIMUM_WAIT_OBJECTS) > 0 )
      {
      loops++
      }

      Fix 2:
      count = qMin(handlesCopy.count() - offset, MAXIMUM_WAIT_OBJECTS);
      if ( count > 0 )
      {
      ret = WaitForMultipleObjects(count, handlesCopy.constData() + offset, false, 100);
      }

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            lkuoza Leonid Kuoza
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes