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

Subject: RE: NDArrayPool:reserve ERROR, reference count = 0, should be = 1
From: "Daykin, Evan via Tech-talk" <tech-talk at aps.anl.gov>
To: Mark Rivers <rivers at cars.uchicago.edu>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Tue, 3 May 2022 15:52:04 +0000

Hm… I am not explicitly calling release() anywhere. This is my processCallbacks function-  everything else in my plugin, AFAIK, doesn’t access any shared resources.

 

void NDPluginTemperature::processCallbacks(NDArray *pArray){

    static const char *functionName = "processCallbacks";

    NDArrayInfo_t arrayInfo;

    if(pArray->dataType != NDUInt16){

        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,

        "%s:%s: Only UInt16 supported.", driverName, functionName);

        return;

    }

    std::string lastCalFileName = this->calibrationFileName;

    getStringParam(this->calibrationFileNameIdx, this->calibrationFileName);

    if(this->calibrationFileName != lastCalFileName){

        this->processCalibrationFile();

    }

    int arrayCallbacks;

    getIntegerParam(NDArrayCallbacks, &arrayCallbacks);

    if(arrayCallbacks==1){

        epicsTimeStamp before;

        epicsTimeGetCurrent(&before);

        NDPluginDriver::beginProcessCallbacks(pArray);

        this->pNDArrayPool->convert(pArray,&(this->inputArray), NDUInt16);

        if(NULL == this->outputArray){

            this->pNDArrayPool->convert(pArray,&(this->outputArray),NDUInt16);

        }

        //unlock while the plug-and-chug happens. No shared resources are accessed at this time.

        inputArray->getInfo(&arrayInfo);

        this->unlock();

        this->doTemperatureConversion(this->inputArray, this->outputArray, &arrayInfo);

        this->lock();

        setIntegerParam(NDArraySizeX, (int)outputArray->dims[arrayInfo.xDim].size);

        setIntegerParam(NDArraySizeY, (int)outputArray->dims[arrayInfo.yDim].size);

       epicsTimeStamp after;

        epicsTimeGetCurrent(&after);

        double delta = epicsTimeDiffInSeconds(&after, &before);

        cout<<"Took "<<delta<<" s"<<endl;

        setDoubleParam(runTimeIdx, delta);

        NDPluginDriver::endProcessCallbacks(outputArray, false, true);

        callParamCallbacks();

    }

}

 

From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: Tuesday, May 3, 2022 11:37 AM
To: tech-talk at aps.anl.gov; Daykin, Evan <daykin at frib.msu.edu>
Subject: Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1

 

[EXTERNAL] This email originated from outside of FRIB

Hi Evan,

 

That error probably means you have called NDArray::release() on an array whose reference count is already 0.

 

Most plugins don't need to call release() because it is handled in the base class NDPluginDriver::endProcessCallbacks().

 

Mark

 

 

 


From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Daykin, Evan via Tech-talk <tech-talk at aps.anl.gov>
Sent: Tuesday, May 3, 2022 10:20 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: NDArrayPool:reserve ERROR, reference count = 0, should be = 1

 

Hi,

 

I am hoping there’s an AreaDetector plugin maven here…


I have written a small AD plugin intended to convert our raw camera images into a temperature heatmap, based on a calibrated gain, emissivity and exposure time. To test it, I set up a SimDetector in “peak” mode. I connect my plugin to this simDetector image. I can successfully capture and convert 3 frames. On the fourth frame, my test dies with the following error. Are there any common pitfalls that might cause this?

 

NDArray.uniqueId=1

Do temperature conversion start

Took 0.0937809 s

NDArray.uniqueId=2

Do temperature conversion start

Took 0.0655851 s

NDArray.uniqueId=3

Do temperature conversion start

Took 0.0642867 s

NDArray.uniqueId=4

NDArrayPool:reserve ERROR, reference count = 0, should be >= 1, pArray=0x7f453c001d80

Thread SimDetTask (0x5621bbbb0c80) can't proceed, suspending.

Dumping a stack trace of thread 'SimDetTask':

[    0x7f45538ffab3]: /lib/x86_64-linux-gnu/libCom.so.3.15.9(epicsStackTrace+0x73)

[    0x7f45538f0216]: /lib/x86_64-linux-gnu/libCom.so.3.15.9(cantProceed+0xc6)

[    0x7f4553197b08]: /lib/x86_64-linux-gnu/libADBase.so.3.11(_ZN11NDArrayPool7reserveEP7NDArray+0x78)

[    0x7f455305db37]: /lib/x86_64-linux-gnu/libNDPlugin.so.3.11(_ZN14NDPluginDriver21beginProcessCallbacksEP7NDArray+0x367)

[    0x7f455375df1e]: /home/daykin/git/areadetector-temperature/lib/linux-x86_64/libNDPluginTemperature.so(_ZN19NDPluginTemperature16processCallbacksEP7NDArray+0xae)

[    0x7f455305dd53]: /lib/x86_64-linux-gnu/libNDPlugin.so.3.11(_ZN14NDPluginDriver14driverCallbackEP8asynUserPv+0x1d3)

[    0x7f4553851155]: /lib/x86_64-linux-gnu/libasyn.so.4.38(_ZN14asynPortDriver25doCallbacksGenericPointerEPvii+0x1f5)

[    0x7f4553809974]: /usr/lib/epics/lib/linux-x86_64/libsimDetector.so(_ZN11simDetector7simTaskEv+0x4e4)

[    0x7f45538fa0bb]: /lib/x86_64-linux-gnu/libCom.so.3.15.9(epicsSnprintf+0x7bb)

[    0x7f4553387ea7]: /lib/x86_64-linux-gnu/libpthread.so.0(start_thread+0xd7)

[    0x7f455349edef]: /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)

 

Evan Daykin

Controls Engineer

Facility for Rare Isotope Beams

Michigan State University

640 South Shaw Lane

East Lansing, MI 48824, USA

Tel. 517-908-7678

Email: daykin at frib.msu.edu

cid:image002.jpg@01D07041.57B6D750

 

 


Replies:
Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Michael Davidsaver via Tech-talk
References:
NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Daykin, Evan via Tech-talk
Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Mark Rivers via Tech-talk
Next: Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Michael Davidsaver via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
Navigate by Thread:
Prev: Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Mark Rivers via Tech-talk
Next: Re: NDArrayPool:reserve ERROR, reference count = 0, should be = 1 Michael Davidsaver via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
ANJ, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·