Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017 
<== Date ==> <== Thread ==>

Subject: RE: iocLogClient and atExit crash
From: <freddie.akeroyd@stfc.ac.uk>
To: <mdavidsaver@gmail.com>, <tech-talk@aps.anl.gov>
Date: Fri, 9 Oct 2015 18:19:02 +0000
Hi Michael,

Thank you for the pointer. I tried to reproduce my issue with a simpler test program so I could then try with 3.15 but the simpler test didn't fail of course. The crash is caused when an exit handler registered through epicsAtExit() happened to call errlogSevPrintf() but putting this logic into a simpler test program didn't produce the same race condition and fail, I'm not sure if the original failing IOC would compile with 3.15 so will need to check.

I applied the 3.15 logic to my 3.14.12.4 distribution and added

	errlogRemoveListener(logClientSendMessage); 

to logClientDestroy() at a similar point and that fixes my crash too, so I suspect 3.15 would also work OK. I do, however, get a "errlogRemoveListener did not find listener" message which I suspect is caused by it trying to find the caPutLog client in the errlog listener list. 

In 3.15 I see that a listener can be deleted by matching on both pPrivate and listener function, but that function is not currently present in 3.14 so both the above and my original suggestion could theoretically remove the wrong listener. Assuming exit handlers are called in reverse order of addition, I think walking the listener list in errlogRemoveListener() in reverse could prevent this, but using the new function from 3.15 is probably a safer approach!

Regards,

Freddie

> -----Original Message-----
> From: Michael Davidsaver [mailto:mdavidsaver@gmail.com]
> Sent: 08 October 2015 19:40
> To: Akeroyd, Freddie (STFC,RAL,ISIS); tech-talk@aps.anl.gov
> Subject: Re: iocLogClient and atExit crash
> 
> It looks like something similar has been done one the 3.15 and 3.16
> (logClientDestroy calls errlogRemoveListeners).  Any chance you can test
> with >=3.15.1 to verify the fix?
> 
> Actually, it looks to me like the call to errlogRemoveListeners could be
> moved to the beginning of logClientDestroy, before the client thread is
> stopped.
> 
> 
> On 10/08/2015 01:53 PM, freddie.akeroyd@stfc.ac.uk wrote:
> > Hi,
> >
> > I had an IOC crash during exiting while in logClientSend() - errlogThread()
> was trying to send a message after logClientDestroy() had already been called
> by epicsExitCallAtExits(). I was able to remove the crash by adding the line:
> >
> > 	epicsAtExit(errlogRemoveListener, (void*)listener);
> >
> > to the end of the errlogAddListener() function so that the log client is
> removed from the listener list before it is destroyed. I hope that is the
> correct fix.
> >
> > This was running base 3.14.12.4 on window x64 compiled with VS 2010
> >
> > Regards,
> >
> > Freddie
> >
> >


References:
iocLogClient and atExit crash freddie.akeroyd
Re: iocLogClient and atExit crash Michael Davidsaver

Navigate by Date:
Prev: Re: TMCM-3110 3-axis controller Florian Feldbauer
Next: how to make AXIS 214 PTZ network camera into EPICS and CSS hongchunxia
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017 
Navigate by Thread:
Prev: Re: iocLogClient and atExit crash Andrew Johnson
Next: TMCM-3110 3-axis controller Peredkov, Sergey
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·