EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Problem with libCom/osi/os/WIN32/osdTime.cpp in 3.14.10
From: "Mark Rivers" <[email protected]>
To: <[email protected]>
Date: Mon, 24 Nov 2008 17:00:14 -0600
Folks,

I've found a bug in osdTime.cpp for win32-x86 in 3.14.10.  The problem
is a race condition at initialization that can cause the IOC to crash as
soon as it starts.

Andrew Johnson solved it with the following patch, but since he is gone
for a while I thought I would send this fix out in case others are
having the same problem.

Cheers,
Mark



Index: osdTime.cpp
===================================================================
RCS file:
/net/phoebus/epicsmgr/cvsroot/epics/base/src/libCom/osi/os/WIN32/osdTime
.cpp,v
retrieving revision 1.38.2.7
diff -u -r1.38.2.7 osdTime.cpp
--- osdTime.cpp 26 Aug 2008 20:31:09 -0000      1.38.2.7
+++ osdTime.cpp 24 Nov 2008 22:53:47 -0000
@@ -85,7 +85,7 @@
     epicsTimerNotify::expireStatus expire ( const epicsTime & );
 };
 
-static currentTime * pCurrentTime = 0;
+static volatile currentTime * pCurrentTime = 0;
 static const LONGLONG FILE_TIME_TICKS_PER_SEC = 10000000;
 static const LONGLONG EPICS_TIME_TICKS_PER_SEC = 1000000000;
 static const LONGLONG ET_TICKS_PER_FT_TICK =
@@ -96,12 +96,13 @@
 //
 static int timeRegister(void)
 {
-    pCurrentTime = new currentTime ();
     /* Must register with generalTime here since the epicsTimer
      * in the PLL ends up calling epicsTime::getCurrent()
      */
     generalTimeCurrentTpRegister("PerfCounter", 150,
osdTimeGetCurrent);
-    pCurrentTime->startPLL ();
+
+    pCurrentTime = (volatile currentTime *)new currentTime ();
+    ((currentTime *)pCurrentTime)->startPLL ();
     return 1;
 }
 static int done = timeRegister();
@@ -111,11 +112,11 @@
 //
 static int osdTimeGetCurrent ( epicsTimeStamp *pDest )
 {
-    if ( ! pCurrentTime ) {
-        return epicsTimeERROR;
+    while ( ! pCurrentTime ) {
+        Sleep(1);
     }
 
-    pCurrentTime->getCurrentTime ( *pDest );
+    ((currentTime *)pCurrentTime)->getCurrentTime ( *pDest );
     return epicsTimeOK;
 }



Navigate by Date:
Prev: Re: USE of CA lib: problem using ca_array_put_callback with strings haquin
Next: areaDetector R1-3 released Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: CSS 1.1.0 Hatje, Jan
Next: areaDetector R1-3 released Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·