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  2022  <20232024  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  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: Re: Help developing AD plugin
From: "Marco A. Barra Montevechi Filho 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>
Cc: SWC <swc at lnls.br>
Date: Wed, 16 Aug 2023 21:23:44 +0000
I see! It seems to be null indeed:

Thread 146 "Warp1_Plugin_1" hit Breakpoint 1, NDPluginWarp::processCallbacks (this=0x558584ea99f0, pArray=0x7ff1480424c0)
    at ../NDPluginWarp.cpp:129
warning: Source file is more recent than executable.
129       NDPluginDriver::endProcessCallbacks(pOutput, true, true);
(gdb) x /p pArray->pData
0x7ff169270010:   Undefined output format "p".
(gdb) x %p pArray->pData
A syntax error in _expression_, near `%p pArray->pData'.
(gdb) print pArray
$1 = (NDArray *) 0x7ff1480424c0
(gdb) print pOutput
$2 = (NDArray *) 0x0
(gdb)

I blindly copied this from NDWarp but i could swear that NDWarp used this parameter as true...

Anyway, i changed it to true and now im having a segfault. I tried printing the address both via code and via gdb. I added:

NDArray
*p;


to the code and

p = this->pNDArrayPool->copy(pArray, pOutput, true, true, true);
printf("%p\n",pOutput);
printf("%p\n",pArray);

I ran the IOC in gdb (Log appended in the end of this email) but it seems to me as a NULL pointer indeed.
What i dont understand is: NDWarp is looking at the SIM1 port from SimDetector. Why is copy failing?

The only thing i changed is that the frame size generated by ADSim is 3072x3072 pixels instead of 1024x1024. Should this matter?

GDB END LOG:

epics> [Thread 0x7f9f55267700 (LWP 13504) exited]
[Thread 0x7f9ff89c7700 (LWP 13503) exited]
[New Thread 0x7f9ff89c7700 (LWP 13506)]
[New Thread 0x7f9f55267700 (LWP 13507)]
[New Thread 0x7f9fa7b41700 (LWP 13508)]
[New Thread 0x7f9f55066700 (LWP 13509)]
[Thread 0x7f9f55066700 (LWP 13509) exited]
[Thread 0x7f9fa7b41700 (LWP 13508) exited]
[New Thread 0x7f9fa7b41700 (LWP 13510)]
[New Thread 0x7f9f55066700 (LWP 13511)]
[Thread 0x7f9fa7b41700 (LWP 13510) exited]
[Thread 0x7f9f55066700 (LWP 13511) exited]
a
(nil)
--Type <RET> for more, q to quit, c to continue without paging--
[Switching to Thread 0x7fa029d92b80 (LWP 13422)]

Thread 146 "Warp1_Plugin_1" hit Breakpoint 1, NDPluginWarp::processCallbacks (this=0x556321cd7930, pArray=0x7f9f3c0017a0) at ../NDPluginWarp.cpp:130
130       printf("%p\n",pArray);
(gdb) backtrace
#0  NDPluginWarp::processCallbacks (this=0x556321cd7930, pArray=0x7f9f3c0017a0) at ../NDPluginWarp.cpp:130
#1  0x00007fa02cb78b69 in NDPluginDriver::processTask (this=0x556321cd7930) at ../NDPluginDriver.cpp:524
#2  0x00007fa02c89545f in epicsThreadCallEntryPoint (pPvt=0x556321cd39a0) at ../../../src/libCom/osi/epicsThread.cpp:83
#3  0x00007fa02c89b4fb in start_routine (arg=0x556323c80530) at ../../../src/libCom/osi/os/posix/osdThread.c:403
#4  0x00007fa02ba9c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#5  0x00007fa02c77d133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) frame 0
#0  NDPluginWarp::processCallbacks (this=0x556321cd7930, pArray=0x7f9f3c0017a0) at ../NDPluginWarp.cpp:130
130       printf("%p\n",pArray);
(gdb) info locals
info = {nElements = 9437184, bytesPerElement = 1, totalBytes = 9437184, colorMode = NDColorModeMono, xDim = 0, yDim = 1, colorDim = 0, xSize = 3072,
  ySize = 3072, colorSize = 0, xStride = 1, yStride = 3072, colorStride = 0}
pOutput = 0x0
p = <optimized out>
__PRETTY_FUNCTION__ = "virtual void NDPluginWarp::processCallbacks(NDArray*)"


From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 16 August 2023 17:56
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Cc: SWC <swc at lnls.br>
Subject: RE: Help developing AD plugin
 

Hi Marco,

 

Since you passed copyArray=false to endProcessCallbacks then it appears to me that the pArray you passed to that function must be NULL.

 

You should check the status return of NDArrayPool->copy() and you should print the value of the pOutput pointer returned from that function using the %p format.

 

Mark

 

 

 

From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Marco A. Barra Montevechi Filho via Tech-talk
Sent: Wednesday, August 16, 2023 3:39 PM
To: tech-talk at aps.anl.gov
Cc: SWC <swc at lnls.br>
Subject: Help developing AD plugin

 

Hi all, we are developing a geometric restoration plugin here at Sirius for areaDetector

Im using NDWarp as a base just because it seems to work as a good example. Also, im unfortunately bound to EPICS 3.15.6, AreaDetector R3-7.

Taking NDWarp as a base, i basically stripped everything between NDPluginWarp::processCallbacks and NDPluginWarp::endProcessCallbacks, so the code is what i append at the end of this e-mail: it should only copy the original array that comes to it and pass it to the other connected plugins.

By compiling and running an IOC with this plugin, when i enable its callbacks i get the following message in my ioc shell:

2023/08/16 17:29:51.666 NDPluginDriver::endProcessCallbacks: Couldn't allocate output array. Further processing terminated.

Although i tried reading the source code, using gdb and recompiling ADCore by adding -g to USR_CXXFLAGS_Linux ad stepping into each function, etc. etc. i couldnt figure out what am i doing wrong. Am i passing a NULL array to  NDPluginDriver::endProcessCallbacks?

Are there any hints about this?

Thanks in advance,

Marco


CODE PART:

NDPluginWarp::processCallbacks(NDArray *pArray)

{

    // pArray is borrowed reference.  Caller will release()

 

    NDPluginDriver::beginProcessCallbacks(pArray);

 

    NDArrayInfo info;

    NDArray *pOutput;

    (void)pArray->getInfo(&info);

 

    if(pArray->ndims!=2 || info.xSize==0 || info.ySize==0) {

        asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,

                  "%s:: 2D non-empty expected",

                  this->portName);

        return;

    }

    switch(pArray->dataType) {

    case NDInt8:

    case NDUInt8:

    case NDInt16:

    case NDUInt16:

    case NDInt32:

    case NDUInt32:

    case NDFloat32:

    case NDFloat64:

        break;

    default:

        asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,

                  "%s:: Unsupported type %u",

                  this->portName, (unsigned)pArray->dataType);

        return;

    }

    asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, "%s: %s ndarray=%p\n", this->portName, __PRETTY_FUNCTION__, pArray);

 

    printf("a\n");

    this->pNDArrayPool->copy(pArray, pOutput, true, true, true);

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


}



 

Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta ao remetente antes de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.

Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying to the sender before copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.


Replies:
RE: Help developing AD plugin Mark Rivers via Tech-talk
References:
Help developing AD plugin Marco A. Barra Montevechi Filho via Tech-talk
RE: Help developing AD plugin Mark Rivers via Tech-talk

Navigate by Date:
Prev: RE: Help developing AD plugin Mark Rivers via Tech-talk
Next: RE: Help developing AD plugin Mark Rivers 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  2022  <20232024 
Navigate by Thread:
Prev: RE: Help developing AD plugin Mark Rivers via Tech-talk
Next: RE: Help developing AD plugin Mark Rivers 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  2022  <20232024 
ANJ, 16 Aug 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·