This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Fix race in cygthread when simplestub is used
- From: Arto Huusko <arto dot huusko at wmdata dot fi>
- To: cygwin-patches at cygwin dot com
- Date: Fri, 29 Jul 2005 13:44:21 +0300
- Subject: Fix race in cygthread when simplestub is used
There is a race condition between cygthread::cygthread and
cygthread::simplestub. If cygthread::simplestub is used, it is possible
that "ev" field is never initialized, which leads to hang when
cygthread::operator HANDLE() is called.
2005-07-29 Arto Huusko <arto.huusko@wmdata.fi>
* cygthread.cc (cygthread::simplestub): fix race.
--- cygthread.cc 2005-07-29 11:30:07.641054271 +0300
+++ cygthread.cc.fixed 2005-07-29 11:30:39.990220737 +0300
@@ -111,6 +111,8 @@ cygthread::simplestub (VOID *arg)
cygthread *info = (cygthread *) arg;
_my_tls._ctinfo = info;
info->stack_ptr = &arg;
+ while (! info->h)
+ low_priority_sleep (0);
info->ev = info->h;
info->func (info->arg == cygself ? info : info->arg);
return 0;