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  <20132014  2015  2016  2017  2018  2019  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: Custom file saving plugin in AreaDetector
From: Hinko Kočevar <hinko.kocevar@i-tech.si>
To: EPICS tech-talk <tech-talk@aps.anl.gov>
Date: Thu, 18 Jul 2013 12:47:49 +0200
Hi,

Segmentation fault happens when saving data to a file from my custom made file saving plugin, that extends the NDPluginFile base class like all other file saving plugins. Saving mode is Capture, meaning a capture buffer, of user specified capture size, is preallocated in advance. During capturing, NDArrays are put into this buffer through callbacks. Actual file saving can occur either when the number of captures(captured NDArrays) reaches the number specified by the user, or when the user manually clicks save before the actually capturing has finished. When saving is done, the preallocated capture buffer is freed. If capturing is still carried on after the saving, which does happen in the case of user clicking save prematurely before the capturing reaches the number specified by the user, segmentation fault happens. The segmentation fault happens in code NDPluginFile.cpp at line 594 (EPICS base 3.14.12.3):

591 case NDFileModeCapture:
592 if (capture) {
593 if (numCaptured < numCapture) {
594 this->pNDArrayPool->copy(pArray, this->pCapture[numCaptured++], 1);
595 arrayCounter++;
596 setIntegerParam(NDFileNumCaptured, numCaptured);

Inspecting the segmentation fault, pCapture was a NULL pointer, the numCaptured was the size of captured NDArrayes at clicking save prematurely.

Since the capture buffer is freed after save, I will avoid this problem by stopping the capture when save is done.

Is a better way to handle this? Maybe there should be a check in the code to avoid segmentation fault, when the NDArray buffer is NULL.

Best regards,
Hinko


--
Hinko Kocevar
Software development engineer
Instrumentation Technologies d.d.
Velika pot 22, SI-5250 Solkan - Slovenia
T:+386 5 3352600, F:+386 5 3352601
E-mail: hinko.kocevar@i-tech.si
http://www.i-tech.si

The information transmitted is intended solely for the
addressee and may contain confidential and/or privileged
information. Any review, retention, disclosure or other use
by persons other than the intended recipient is prohibited.
If you received this in error, please notify the sender and
delete all copies.


Replies:
RE: Custom file saving plugin in AreaDetector Mark Rivers

Navigate by Date:
Prev: auto correlator support Daron Chabot
Next: motor record & PC6K: program upload fails Konrad, Martin
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
Navigate by Thread:
Prev: auto correlator support Daron Chabot
Next: RE: Custom file saving plugin in AreaDetector Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·