public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used
@ 2014-01-14 15:30 ahanins at gmail dot com
2014-01-14 15:33 ` [Bug libstdc++/59807] " ahanins at gmail dot com
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: ahanins at gmail dot com @ 2014-01-14 15:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
Bug ID: 59807
Summary: mutex misses destructor if non-function call
initialization is used
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: ahanins at gmail dot com
Hi,
Follow up to https://sourceforge.net/p/mingw-w64/bugs/376/
This is related to GTHR interface to pthread.
C++11 __mutex_base class does not define a destructor if __GTHREAD_MUTEX_INIT
is defined. It means, underlying implementation (pthread for example) has no
any means to do a resource cleanup when std::mutex is destructed. In
particular, it causes semaphore object resource (handle) leak on Windows in
MinGW winpthread implementation where semaphore object is created during first
pthread_mutex_lock invocation.
Wouldn't it be more robust to always define a destructor for __mutex_base
which calls __gthread_mutex_destroy, or even more flexibly, introduce a
separate macro like __GTHREAD_MUTEX_DESTROY_FUNCTION which controls whether
destructor should be defined at all or not.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
@ 2014-01-14 15:33 ` ahanins at gmail dot com
2014-01-14 17:19 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ahanins at gmail dot com @ 2014-01-14 15:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #1 from Andrey H. <ahanins at gmail dot com> ---
Simplest code which leaks handles on Windows:
for(;;) {
std::mutex op_mutex;
op_mutex.lock();
op_mutex.unlock();
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
2014-01-14 15:33 ` [Bug libstdc++/59807] " ahanins at gmail dot com
@ 2014-01-14 17:19 ` redi at gcc dot gnu.org
2014-01-14 17:22 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-14 17:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It a target's pthread_mutex requires cleanup then it should not define
__GTHREAD_MUTEX_INIT, it should use the init function, and then it gets a
chance to also run a destroy function.
That can be controlled by defining _GTHREAD_USE_MUTEX_INIT_FUNC in the relevant
libstdc++-v3/config/os/xxx/os_defines.h header.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
2014-01-14 15:33 ` [Bug libstdc++/59807] " ahanins at gmail dot com
2014-01-14 17:19 ` redi at gcc dot gnu.org
@ 2014-01-14 17:22 ` redi at gcc dot gnu.org
2014-01-29 19:03 ` ahanins at gmail dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-14 17:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In other words, we already have all the machinery in place to handle such
cases, it just needs to be used for the target.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
` (2 preceding siblings ...)
2014-01-14 17:22 ` redi at gcc dot gnu.org
@ 2014-01-29 19:03 ` ahanins at gmail dot com
2014-01-29 19:53 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ahanins at gmail dot com @ 2014-01-29 19:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #4 from Andrey H. <ahanins at gmail dot com> ---
Thanks Jonathan, I followed your suggestion regarding os_defines.h, recompiled
the whole mingw-w64 toolchain and can confirm that it helps. But doesn't it
meant that it should be fixed in GCC sources itself (I mean in
libstdc++-v3/config/os/mingw32-w64/os_defines.h). Or there is other standard
way how to influence os_defines.h during configuration phase?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
` (3 preceding siblings ...)
2014-01-29 19:03 ` ahanins at gmail dot com
@ 2014-01-29 19:53 ` redi at gcc dot gnu.org
2014-01-29 20:26 ` ktietz at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-29 19:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, the copy in the sources needs to be fixed. Does mingw-w64 always use
winpthread?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
` (4 preceding siblings ...)
2014-01-29 19:53 ` redi at gcc dot gnu.org
@ 2014-01-29 20:26 ` ktietz at gcc dot gnu.org
2014-01-30 7:32 ` ahanins at gmail dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-01-29 20:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
Kai Tietz <ktietz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-01-29
Ever confirmed|0 |1
--- Comment #6 from Kai Tietz <ktietz at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> Yes, the copy in the sources needs to be fixed. Does mingw-w64 always use
> winpthread?
Sadly, no. The use of POSIX-threading is optional. That was actual the reason
why I didn't added it by default. We would need to probe if pthread-library is
present, and just then activate enable it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
` (5 preceding siblings ...)
2014-01-29 20:26 ` ktietz at gcc dot gnu.org
@ 2014-01-30 7:32 ` ahanins at gmail dot com
2014-10-14 12:38 ` redi at gcc dot gnu.org
2014-10-14 13:09 ` ktietz at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ahanins at gmail dot com @ 2014-01-30 7:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #7 from Andrey H. <ahanins at gmail dot com> ---
Kai, so what would be the fix?
IMHO, this bug is quite a show stopper for C++11 threading in Mingw-w64, so
maybe it worth to create a temporary patch for Mingw-w64 compilation with
pthreads support just to have a working toolchain?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
` (6 preceding siblings ...)
2014-01-30 7:32 ` ahanins at gmail dot com
@ 2014-10-14 12:38 ` redi at gcc dot gnu.org
2014-10-14 13:09 ` ktietz at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-14 12:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If the target for this is only mingw-w64 then PR 57440 is a dup
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/59807] mutex misses destructor if non-function call initialization is used
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
` (7 preceding siblings ...)
2014-10-14 12:38 ` redi at gcc dot gnu.org
@ 2014-10-14 13:09 ` ktietz at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ktietz at gcc dot gnu.org @ 2014-10-14 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807
Kai Tietz <ktietz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #9 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Agreed, this bug is duplicate of PR/57440
*** This bug has been marked as a duplicate of bug 57440 ***
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-10-14 13:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-14 15:30 [Bug libstdc++/59807] New: mutex misses destructor if non-function call initialization is used ahanins at gmail dot com
2014-01-14 15:33 ` [Bug libstdc++/59807] " ahanins at gmail dot com
2014-01-14 17:19 ` redi at gcc dot gnu.org
2014-01-14 17:22 ` redi at gcc dot gnu.org
2014-01-29 19:03 ` ahanins at gmail dot com
2014-01-29 19:53 ` redi at gcc dot gnu.org
2014-01-29 20:26 ` ktietz at gcc dot gnu.org
2014-01-30 7:32 ` ahanins at gmail dot com
2014-10-14 12:38 ` redi at gcc dot gnu.org
2014-10-14 13:09 ` ktietz at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).