|
From: Alexander P. <gl...@go...> - 2016-03-21 13:56:17
|
On Sat, Mar 19, 2016 at 10:02 PM, David Faure <fa...@kd...> wrote:
> The following code (from Qt5's qlogging.cpp)
>
> static thread_local bool msgHandlerGrabbed = false;
>
> static bool grabMessageHandler()
> {
> if (msgHandlerGrabbed)
> return false;
>
> msgHandlerGrabbed = true;
> return true;
> }
>
> static void ungrabMessageHandler()
> {
> msgHandlerGrabbed = false;
> }
>
> (purpose: avoiding recursion)
>
> when compiled with clang 3.5.0, and called from multiple threads, leads to this helgrind warning:
>
> ==1218== Possible data race during write of size 1 at 0x1E1F86F0 by thread #17
> ==1218== Locks held: none
> ==1218== at 0x783637B: grabMessageHandler() (qlogging.cpp:1543)
> ==1218== by 0x783640B: qt_message_print(QtMsgType, QMessageLogContext const&, QString const&) (qlogging.cpp:1571)
> ==1218== by 0x783658A: qt_message_output(QtMsgType, QMessageLogContext const&, QString const&) (qlogging.cpp:1622)
> ==1218== by 0x798DC32: QDebug::~QDebug() (qdebug.cpp:150)
> ==1218== by 0x4F24EF6: CompletionThread::done() (kurlcompletion.cpp:232)
> ==1218== by 0x4F1ECCD: DirectoryListThread::run() (kurlcompletion.cpp:368)
> ==1218== by 0x784B0B6: QThreadPrivate::start(void*) (qthread_unix.cpp:340)
> ==1218== by 0x4C3005E: mythread_wrapper (hg_intercepts.c:389)
> ==1218== by 0x9DAE0A3: start_thread (pthread_create.c:309)
> ==1218== by 0x869100C: clone (clone.S:111)
> ==1218==
> ==1218== This conflicts with a previous write of size 1 by thread #16
> ==1218== Locks held: none
> ==1218== at 0x7836399: ungrabMessageHandler() (qlogging.cpp:1549)
> ==1218== by 0x78364BC: qt_message_print(QtMsgType, QMessageLogContext const&, QString const&) (qlogging.cpp:1579)
> ==1218== by 0x783658A: qt_message_output(QtMsgType, QMessageLogContext const&, QString const&) (qlogging.cpp:1622)
> ==1218== by 0x798DC32: QDebug::~QDebug() (qdebug.cpp:150)
> ==1218== by 0x4F24EF6: CompletionThread::done() (kurlcompletion.cpp:232)
> ==1218== by 0x4F1ECCD: DirectoryListThread::run() (kurlcompletion.cpp:368)
> ==1218== by 0x784B0B6: QThreadPrivate::start(void*) (qthread_unix.cpp:340)
> ==1218== by 0x4C3005E: mythread_wrapper (hg_intercepts.c:389)
> ==1218== Address 0x1e1f86f0 is in a rw- anonymous segment
>
> Helgrind bug, or is clang silently ignoring thread_local?
Clang documentation (http://clang.llvm.org/cxx_status.html) says
thread_local support requires libc++abi 3.6+ or libsupc++ 4.8+.
Does your binary use any of those?
> --
> David Faure, fa...@kd..., http://www.davidfaure.fr
> Working on KDE Frameworks 5
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
|