Code review comment for lp:~johill-lanl/epics-base/epicsThreadOnce-atomics-based

Revision history for this message
Andrew Johnson (anj) wrote :

Hi Jeff,

The epicsThreadOnce.cpp file has an essential function epicsThreadOnceOnly() which calls cantProceed(), epicsThreadSleep() and errlogPrintf() [the cantProceed() function also calls both of the other two]. Unfortunately both the errlog and generalTime facilities rely on epicsThreadOnce during initialization, thus this implementation could be subject to circular startup problems.

When I try to boot an IOC on vxWorks 6.8 with this code, it hangs silently while executing the C++ static constructors.

If I replace the errlogPrintf() call with std::printf(), after maybe a 10 second delay waiting for the vxWorks munch file to finish loading I get the message "epicsThreadOnce: waiting for another thread to finish calling the once function" which then repeats forever. Here's the stack of the thread loading the munch file:

0x00206b2c ld +0xb4 : usrModuleLoad ()
0x002069e0 usrModuleLoad+0x1c : loadModule ()
0x001da4c0 loadModule +0x24 : loadModuleAt ()
0x001da3d4 loadModuleAt +0xe0 : 0x001da02c ()
0x001da198 loadLibInit +0x21c: cplusLoadFixup ()
0x002141a4 cplusLoadFixup+0x8c : cplusCallCtors ()
0x00143594 cplusCallCtors+0x28 : _GLOBAL__I_iocshPpdbbase ()
0x010b2bc8 _GLOBAL__I_iocshPpdbbase+0x28 : 0x010b2ae8 ()
0x010b2b44 iocshRegister+0x210: iocshRegister ()
0x010b2978 iocshRegister+0x44 : 0x010b0d40 ()
0x010b0d70 gphInitPvt +0x16c: epicsThreadOnce ()
0x010bdfc4 epicsThreadOnce+0xfc : 0x010c59bc (0x8000003c)
0x010c5a44 epicsThreadSleep+0x8c : taskDelay ()

I suspect it may not be possible to fix this in a generic, portable fashion. The current implementations of epicsThreadOnce() are all OS-specific and understand the OS-specific startup requirements. However I'd be happy to test a revised version if you manage to get it working properly on vxWorks.

- Andrew

review: Needs Fixing

« Back to merge proposal