This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Fwd: Handle leak ?]


There will be a new snapshot available in the next few days which
will include the following patch in create.c:pthread_create().

This patch fixes the handle leak reported by David Baggett and
Paul Redondo.

Thanks go to Eyal Lebedinsky who spotted the root cause
and David Baggett for testing it:

Explanation
-----------
When threads were being started as "running", short
threads would sometimes reach the cleanup code in
_pthread_threadDestroy() before _beginthreadex returned with the
Win32 thread handle; ie. thread->threadH would be NULL and the
handle would never get closed.


 thread->threadH = (HANDLE)
   _beginthreadex (
                   (void *) NULL,     /* No security info */
                   (unsigned) stackSize,    /* default stack size */
                   (unsigned (PT_STDCALL *) (void *))
_pthread_threadStart,
                   parms,
                   (unsigned) CREATE_SUSPENDED,
                   (unsigned *) &(thread->thread));

 if (thread->threadH != (HANDLE) 0 && run)
   {
      ResumeThread(thread->threadH);
   }


Ross

-- 
+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]