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

Please make it convenient to analyze Qt programs with one of Valgrind's thread checking tools

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.6.0, 6.7
    • Core: Threads
    • None

    Description

      Analyzing Qt programs with one of Valgrind's thread checking tools results in lots of false positives – actually so much false positives that it becomes too tedious to filter out the real issues manually (see also the attachments qt4_mutex.cpp and qt4_mutex-drd-output.txt for an example). It would be great if annotations could be added to the right Qt primitives such that these false positives are suppressed. One family of primitives that will have to be instrumented is the group of Q_GLOBAL_STATIC*() macros. Adding these macro's as follows will probably suppress the false positives reported on the usage of the singleton pattern via one of the Q_GLOBAL_STATIC*() macro's (see also the header file helgrind/helgrind.h distributed via Valgrind 3.5.0 for the definitions of the ANNOTATE_HAPPENS_BEFORE() and ANNOTATE_HAPPENS_AFTER() macros):

      $ diff -u orig/qt-everywhere-opensource-src-4.6.0-beta1/src/corelib/global/qglobal.h qt4.6.0b1/src/corelib/global/qglobal.h
      --- orig/qt-everywhere-opensource-src-4.6.0-beta1/src/corelib/global/qglobal.h 2009-10-13 11:34:08.000000000 -0400
      +++ qt4.6.0b1/src/corelib/global/qglobal.h      2009-11-10 04:56:37.000000000 -0500
      @@ -43,6 +43,7 @@
       #define QGLOBAL_H
      
       #include <stddef.h>
      +#include <Qt/private/helgrind_p.h>
      
       #define QT_VERSION_STR "4.6.0"
       /*
      @@ -1789,9 +1790,13 @@
                   TYPE *x = new TYPE;                                         \
                   if (!this_##NAME.pointer.testAndSetOrdered(0, x))           \
                       delete x;                                               \
      -            else                                                        \
      +            else {                                                      \
      +                ANNOTATE_HAPPENS_BEFORE(&this_##NAME.pointer);          \
                       static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
      +            }                                                           \
               }                                                               \
      +        else                                                            \
      +            ANNOTATE_HAPPENS_AFTER(&this_##NAME.pointer);               \
               return this_##NAME.pointer;                                     \
           }
      
      @@ -1803,9 +1808,13 @@
                   TYPE *x = new TYPE ARGS;                                    \
                   if (!this_##NAME.pointer.testAndSetOrdered(0, x))           \
                       delete x;                                               \
      -            else                                                        \
      +            else {                                                      \
      +                ANNOTATE_HAPPENS_BEFORE(&this_##NAME.pointer);          \
                       static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
      +            }                                                           \
               }                                                               \
      +        else                                                            \
      +            ANNOTATE_HAPPENS_AFTER(&this_##NAME.pointer);               \
               return this_##NAME.pointer;                                     \
           }
      
      @@ -1817,10 +1826,13 @@
                   QScopedPointer<TYPE > x(new TYPE);                          \
                   INITIALIZER;                                                \
                   if (this_##NAME.pointer.testAndSetOrdered(0, x.data())) {   \
      +                ANNOTATE_HAPPENS_BEFORE(&this_##NAME.pointer);          \
                       static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
                       x.take();                                               \
                   }                                                           \
               }                                                               \
      +        else                                                            \
      +            ANNOTATE_HAPPENS_AFTER(&this_##NAME.pointer);               \
               return this_##NAME.pointer;                                     \
           }
       

      Note: the attached drd output has been generated with Qt 4.6.0 beta1 compiled from source on an x86_64 system and with the drd tool as included in Valgrind 3.5.0.

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              bart.vanassche Bart Van Assche
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes