Thanks,
Mark
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hinko Kocevar
Sent: Thursday, July 18, 2013 5:48 AM
To: EPICS tech-talk
Subject: Custom file saving plugin in AreaDetector
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