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.

Reply via email to