https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107857
Bug ID: 107857
Summary: recursive_mutex misses destructor if non-function call
initialization is used
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: pg.ensiie at gmail dot com
Target Milestone: ---
Hello,
Using GCC 11.2.0 with mingw-w64 9.0.0.
I notice that there is a memory leak when using a std::recursive_mutex, as
described in this issue : https://sourceforge.net/p/mingw-w64/bugs/851/. I
reproduce this bug.
After some research, I discover that same problem has occured for std::mutex,
that was solved by this fix : https://sourceforge.net/p/mingw-w64/bugs/851/
The solution is to use function initialized and destructor for recursive_mutex
as it is done for mutex when using pthread on windows. Defining
_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC in os_defines.h fixes the bug.
Even if I do not use it, I wonder if _GTHREAD_USE_COND_INIT_FUNC should also be
set for condition variables.