This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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;

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