http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57440

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Using Qt Creator I have confirmed the leak, and can reproduce it with this 

#include <pthread.h>
#include <unistd.h>

int main()
{
    for (int i=0; i < 100000; ++i) {
        pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
        pthread_mutex_lock(&mx);
        pthread_mutex_unlock(&mx);
        usleep(10000);
    }
}

This is a simplified version of the code in libstdc++, here's another leaky
program using libstdc++:

//#define _GTHREAD_USE_MUTEX_INIT_FUNC

#include <mutex>
#include <unistd.h>

int main()
{
    for (int i=0; i < 100000; ++i) {
        std::mutex mx;
        mx.lock();
        mx.unlock();
        usleep(10000);
    }
}

Uncommenting the first line fixes it, so we should define that macro in
libstdc++-v3/config/os/mingw32-w64/os_defines.h

Reply via email to