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 <2023> 2024 2025 | 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 <2023> 2024 2025 |
<== 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 22:02:37 +0000 |
That did it!
I see now, thanks for the tip. No segmentation fault anymore and when i make image plugin look at stripped NDWarp it loads the image in the visualizer normally. Also, i mistakenly added some memory leak but solved it with pOutput->release() after endProcessCallbacks Many thanks! From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 16 August 2023 18:50 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 I believe I see your problem. Your original code had these 2 lines:
NDArray *pOutput;
this->pNDArrayPool->copy(pArray, pOutput, true, true, true);
You created pOutput without setting it to NULL. You then passed it to NDArrayPoolCopy. If that pointer is not NULL then it is treated as a pointer to an existing array to modify.
You should change the code to this:
pOutput = this->pNDArrayPool->copy(pArray, NULL, true, true, true);
NDArrayPool->copy is a function that returns the pointer to the new array. It may be that NDWarp was creating pOutput and passing it to NDArrayPool->copy() which is OK, but your stripped down code was not doing that.
Mark
From: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
I see! It seems to be null indeed: 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) 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:
p = this->pNDArrayPool->copy(pArray, pOutput, true, true, true); printf("%p\n",pOutput); printf("%p\n",pArray);
[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>
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
Hi all, we are developing a geometric restoration plugin here at Sirius for areaDetector 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. |