Subject: [Boost-bugs] [Boost C++ Libraries] #11457: boost::recursive_mutex leaks event handles when lock contention occurs.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-07-08 21:30:13
#11457: boost::recursive_mutex leaks event handles when lock contention occurs.
--------------------------+-----------------------------------------
Reporter: al.mendall@⦠| Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.46.0
Severity: Problem | Keywords: handle leak recursive_mutex
--------------------------+-----------------------------------------
When 2+ threads attempt to acquire a recursive_mutex at the same time, an
event handle may/will be leaked.
This is extremely reproducible in my application. The app runs fine by
the way...the leak does not interfere with the expected behavior. It
merely leaks handles at a very low rate (< 0.01% of the time the lock is
acquired). That rate increases the more threads there are trying to
acquire the same locks.
1. Commenting out the call to lock the recursive_mutex eliminates the
leak.
2. Replacing recursive_mutex with a non-boost lock eliminates the leak.
3. Preventing > 1 thread from trying to acquire the recursive_mutex at at
time also eliminates the leak.
4. The more threads there are fighting over the lock, the more likely it
is that handles will be leaked.
5. The handle leak is 100% reproducible, but the # of leaks varies with
each execution. There is an element of randomness to the quantity of
handles leaked.
Those facts combine to point squarely at lock contention in
recursive_mutex as the culprit.
I also used the handle.exe utility to confirm that the application was
leaking event handles.
My application launches 9 threads that each traverse a vector of ~100k
objects. Each object owns a recursive_mutex. Each threads acquires &
releases each object's lock ~50 times in rapid succession. Each time this
complete cycle is run, the application will leak 250-1500 event handles.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11457> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC