Re: [Valgrind-users] Helgrind causing data race warning in mutex_destroy_WRK?

2021-08-17 Thread Schmidt, Adriaan
> >
> > To me it seems that Helgrind itself is causing the warning when
> > calculating mutex_is_init (hg_intercepts.c:859).
> 
> Isn't this rather a race between unlocking a mutex and destroying that mutex?

I'm not sure... I know it's not a very strong argument, but the Poco::Timer 
code is not that complex, and I could not find anything wrong with it.

What puzzles me is that the location Helgrind reports is "inside" the mutex 
object itself. Is it even possible to create a race on the memory location of a 
mutex, when only accessing it through the pthread_mutex_* API?



___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


Re: [Valgrind-users] Helgrind causing data race warning in mutex_destroy_WRK?

2021-08-17 Thread David Faure
On mardi 17 août 2021 09:59:23 CEST Schmidt, Adriaan wrote:
> Hi.
> 
> Running Helgrind (Valgrind 3.17.0) on arm32 (Linux 4.14.139), glibc 2.31,
> and an application using Poco 1.10.1, I see the following:
> 
> ==17922== Possible data race during read of size 1 at 0x64BD4C4 by thread
> #97 ==17922== Locks held: 1, at address 0x1C134CC
> ==17922==at 0x48536D8: my_memcmp (hg_intercepts.c:220)
> ==17922==by 0x4853BBF: mutex_destroy_WRK (hg_intercepts.c:859)
> ==17922==by 0x48572F7: pthread_mutex_destroy (hg_intercepts.c:882)
> ==17922==by 0x5705F23: Poco::EventImpl::~EventImpl()
> (Event_POSIX.cpp:96) ==17922==by 0x5706393: Poco::Event::~Event()
> (Event.cpp:40)
> ==17922==by 0x578099B: Poco::Timer::~Timer() (Timer.cpp:34)
> ==17922==by 0x5470827: Poco::Data::SessionPool::~SessionPool()
> (SessionPool.cpp:40) ==17922==by 0x54708A7:
> Poco::Data::SessionPool::~SessionPool() (SessionPool.cpp:50) ==.==[
> ... ]
> ==17922==
> ==17922== This conflicts with a previous write of size 4 by thread #7
> ==17922== Locks held: none
> ==17922==at 0x57F8998: __pthread_mutex_unlock_usercnt
> (pthread_mutex_unlock.c:52) ==17922==by 0x4854273: mutex_unlock_WRK
> (hg_intercepts.c:1106) ==17922==by 0x4857337: pthread_mutex_unlock
> (hg_intercepts.c:1124) ==17922==by 0x5781153: setImpl
> (Event_POSIX.h:61)
> ==17922==by 0x5781153: set (Event.h:101)
> ==17922==by 0x5781153: Poco::Timer::run() (Timer.cpp:216)
> ==17922==by 0x577ACAF: Poco::PooledThread::run() (ThreadPool.cpp:199)
> ==17922==by 0x57765B3: Poco::ThreadImpl::runnableEntry(void*)
> (Thread_POSIX.cpp:345) ==17922==by 0x48562FF: mythread_wrapper
> (hg_intercepts.c:398)
> ==17922==by 0x57F4143: start_thread (pthread_create.c:477)
> 
> To me it seems that Helgrind itself is causing the warning when calculating
> mutex_is_init (hg_intercepts.c:859).

Isn't this rather a race between unlocking a mutex and destroying that mutex?

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5





___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


[Valgrind-users] Helgrind causing data race warning in mutex_destroy_WRK?

2021-08-17 Thread Schmidt, Adriaan
Hi.

Running Helgrind (Valgrind 3.17.0) on arm32 (Linux 4.14.139), glibc 2.31, and 
an application using Poco 1.10.1, I see the following:

==17922== Possible data race during read of size 1 at 0x64BD4C4 by thread #97
==17922== Locks held: 1, at address 0x1C134CC
==17922==at 0x48536D8: my_memcmp (hg_intercepts.c:220)
==17922==by 0x4853BBF: mutex_destroy_WRK (hg_intercepts.c:859)
==17922==by 0x48572F7: pthread_mutex_destroy (hg_intercepts.c:882)
==17922==by 0x5705F23: Poco::EventImpl::~EventImpl() (Event_POSIX.cpp:96)
==17922==by 0x5706393: Poco::Event::~Event() (Event.cpp:40)
==17922==by 0x578099B: Poco::Timer::~Timer() (Timer.cpp:34)
==17922==by 0x5470827: Poco::Data::SessionPool::~SessionPool() 
(SessionPool.cpp:40)
==17922==by 0x54708A7: Poco::Data::SessionPool::~SessionPool() 
(SessionPool.cpp:50)
==.==[ ... ]
==17922== 
==17922== This conflicts with a previous write of size 4 by thread #7
==17922== Locks held: none
==17922==at 0x57F8998: __pthread_mutex_unlock_usercnt 
(pthread_mutex_unlock.c:52)
==17922==by 0x4854273: mutex_unlock_WRK (hg_intercepts.c:1106)
==17922==by 0x4857337: pthread_mutex_unlock (hg_intercepts.c:1124)
==17922==by 0x5781153: setImpl (Event_POSIX.h:61)
==17922==by 0x5781153: set (Event.h:101)
==17922==by 0x5781153: Poco::Timer::run() (Timer.cpp:216)
==17922==by 0x577ACAF: Poco::PooledThread::run() (ThreadPool.cpp:199)
==17922==by 0x57765B3: Poco::ThreadImpl::runnableEntry(void*) 
(Thread_POSIX.cpp:345)
==17922==by 0x48562FF: mythread_wrapper (hg_intercepts.c:398)
==17922==by 0x57F4143: start_thread (pthread_create.c:477)

To me it seems that Helgrind itself is causing the warning when calculating 
mutex_is_init (hg_intercepts.c:859).

The conflicting access is a write to the field __data.__owner of the mutex 
(https://elixir.bootlin.com/glibc/glibc-2.31/source/nptl/pthread_mutex_unlock.c#L52).

Any ideas what could be going on here?

Thanks,
Adriaan


___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users