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

Thread sanitizer data races with deleteLater

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.13.1
    • Core: Threads
    • None
    • Linux/X11

    Description

      I got warnings from thread sanitizer when execution this piece of code:

      #include <QThread>
      #include <QCoreApplication>
      
      int main(int argc, char** argv)
      {
          QCoreApplication app{argc, argv};
          QThread          thread;
          auto             object = new QObject;
          object->moveToThread(&thread);
          thread.start();
          object->deleteLater();
          thread.quit();
          thread.wait();
          return 0;
      }
      

      Thread sanitizer reports these data races:

      WARNING: ThreadSanitizer: data race (pid=327160)
        Write of size 8 at 0x7b0800000100 by thread T1:
          #0 operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cc:149 (libtsan.so.0+0x796b5)
          #1 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) <null> (libQt5Core.so.5+0x293742)
      
        Previous write of size 8 at 0x7b0800000100 by main thread:
          #0 operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cc:63 (libtsan.so.0+0x79c6c)
          #1 QObject::deleteLater() <null> (libQt5Core.so.5+0x2ba894)
          #2 __libc_start_main <null> (libc.so.6+0x26ee2)
      
        Thread T1 'QThread' (tid=327162, running) created by main thread at:
          #0 pthread_create /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors.cc:964 (libtsan.so.0+0x2d683)
          #1 QThread::start(QThread::Priority) <null> (libQt5Core.so.5+0xc202b)
          #2 __libc_start_main <null> (libc.so.6+0x26ee2)
      
      SUMMARY: ThreadSanitizer: data race /build/gcc/src/gcc/libsanitizer/tsan/tsan_new_delete.cc:149 in operator delete(void*, unsigned long)
      ==================
      ThreadSanitizer: reported 1 warnings
       

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            salvation Christian Salvasohn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes