|
From: David F. <fa...@kd...> - 2016-03-19 21:03:10
|
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?
--
David Faure, fa...@kd..., http://www.davidfaure.fr
Working on KDE Frameworks 5
|
|
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
|
|
From: David F. <fa...@kd...> - 2016-03-22 08:28:48
|
On Monday 21 March 2016 14:56:09 Alexander Potapenko wrote: > > 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? Oh. I use libstdc++, that's why, then. I had no idea that the feature check for clang could pass and then the feature would fail at runtime due to using another c++ standard library. Tricky. libc++ and libsupc++ don't seem to be packaged for OpenSUSE 13.2, (while clang is) so I'll ignore this for now. Thanks! -- David Faure, fa...@kd..., http://www.davidfaure.fr Working on KDE Frameworks 5 |