leak from main thread

Axel Mamode axel@intrinsic.com
Fri Jul 19 09:46:00 GMT 2002


I know that this is not the intended usage of the pthread library (as it
uses pthread for the main thread),
but the following program leaks two blocks of memory (with
pthreads-snap-2002-03-02):

#include <crtdbg.h>
#include <pthread.h>

int main()
{
// turn on leak detection
  int dbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
  dbgFlag |= _CRTDBG_LEAK_CHECK_DF;
  _CrtSetDbgFlag(dbgFlag);

  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
  return 0;
}

Supposedly, the setcancelstate creates a mutex that is never freed (the
equivalent mutex is freed though
when a posix thread exits).
--
Axel Mamode



More information about the Pthreads-win32 mailing list