Hi, I think that this is a problem in cygthreads, but since I have been looking at cygwin for less than two weeks I might as well be quite mistaken.
The problem can be reproduced with Cygwin 1.7.9-1 and also with today's checkout of the code. To repro run this program form the attachment (compiled using: g++ main.cc) One should observe the program hanging when deleting timer. On my computer it usually is timer 31, but depending on race conditions you might get a different one. If you don't get the problem then try increasing TIMERS. After spending long hours looking at cygwinthread.cc code I have come up with the following patch to fix the problem. I believe that the solution should be bullet-proof also if someone terminates the thread (thread_terminate()) or calls detach(), but since it was the first time I looked at the cygwin code I might as well be wrong. * cygthread.cc (cygthread::simplestub): Notify that the thread has detached also in freerange thread case. Any comments are most welcome, Best wishes, Rafal P.S. Please note that another (completely separate) problem with freerange threads leaking memory in auto_release case exists. I will create another post with info about that.
Index: src/winsup/cygwin/cygthread.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/cygthread.cc,v retrieving revision 1.85 diff -u -p -r1.85 cygthread.cc --- src/winsup/cygwin/cygthread.cc 30 Jul 2011 20:50:23 -0000 1.85 +++ src/winsup/cygwin/cygthread.cc 25 Aug 2011 18:44:32 -0000 @@ -136,7 +136,11 @@ cygthread::simplestub (VOID *arg) cygthread *info = (cygthread *) arg; _my_tls._ctinfo = info; info->stack_ptr = &arg; + HANDLE notify = info->notify_detached; info->callfunc (true); + if (notify) + SetEvent(notify); + return 0; }
main.cc
Description: Binary data
