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

QTest introduce race condition to debug output

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.3
    • Testing: qtestlib
    • None
    • Winows 10 64 bit

      Qt 5.9.3

      MinGW 5.3.0 64 bit

    Description

      Sending debug output messages using qInfo() / qDebug() from several threads created using QtConcurrent::run() inside tests executed by QTest::exec() result in application crush, due to memory corruption inside buffers.

      qInfo() works fine if used in multithreaded environment outisde of Qt test framework, so it looks like the problem is that some message handlers introduced in QTest::exec() contains race conditions.

      Minimal example code which reproduce bug is attached.

      Output of the minimal exmple on my system is as follows:

                      • Start testing of TestClass *********

      Config: Using QtTest library 5.9.3, Qt 5.9.3 (x86_64-little_endian-llp64 shared (dynamic) debug build; by GCC 5.3.0)

      PASS : TestClass::initTestCase()

      QDEBUG : TestClass::TestRaceCondition() This will lead to race condition

      QDEBUG : TestClass::TestRaceCondition() This will lead to race condition

      PASS : TestClass::TestRaceCondition()

      QDEBUG : TestClass::TestRaceCondition() This will lead to race condition

      PASS : TestClass::cleanupTestCase()

      Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 4ms

                      • Finished testing of TestClass *********
                      • Start testing of TestClass *********

      Config: Using QtTest library 5.9.3, Qt 5.9.3 (x86_64-little_endian-llp64 shared (dynamic) debug build; by GCC 5.3.0)

      This will lead to race condition

      alive?

      PASS : TestClass::initTestCase()

      QDEBUG : TestClass::TestRaceCondition() This will lead to race condition

      PASS : TestClass::TestRaceCondition()

      PASS : TestClass::cleanupTestCase()

      Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 1ms

                      • Finished testing of TestClass *********

      This application has requested the Runtime to terminate it in an unusual way.

      Please contact the application's support team for more information.

      This application has requested the Runtime to terminate it in an unusual way.

      Please contact the application's support team for more information.

      I also inculde Qt portion of stack trace of crush in real application. Application uses TeamCity formatting of output, but it is not essential to reproduce crush.

      Attachments

        1. crash.png
          crash.png
          19 kB
        2. main.cpp
          0.6 kB
        3. MinQtBug.pro
          0.8 kB
        4. testobject.h
          0.2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            macadder Jason McDonald
            sergeyvlsorokin Sergey Sorokin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes