EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Crash in pvData
From: Michael Davidsaver via Core-talk <[email protected]>
To: Mark Rivers <[email protected]>, "[email protected]" <[email protected]>
Date: Sat, 29 Jun 2019 08:47:59 -0700
On 6/29/19 7:37 AM, Mark Rivers via Core-talk wrote:
> Folks,
> 
>  
> 
> I have an NDArray with a string attribute holding the value “Continuous”.  When the NDArray gets converted to an NTNDArray in NTNDArrayConverter I am getting this crash:
> 
>  
> 
> #0  0x00007fad6f64e2ad in  () at /lib64/libstdc++.so.6
> 
> #1  0x00007fad6f6b1e5e in std::string::assign(std::string const&) () at /lib64/libstdc++.so.6
> 
> #2  0x00000000006c113d in epics::pvData::detail::ScalarStorageOps<std::string>::store(std::string const&) (__str="Continuous", this=0x7fac14002650)
> 
>     at /usr/include/c++/4.8.2/bits/basic_string.h:547
> 
> #3  0x00000000006c113d in epics::pvData::detail::ScalarStorageOps<std::string>::store(std::string const&) (this=this@entry=0x7fac14002650, val="Continuous")
> 
>     at /usr/local/epics-devel/base-7.0.2/include/pv/pvData.h:362
> 
> #4  0x00000000006cbf41 in NTNDArrayConverter::fromStringAttribute(std::tr1::shared_ptr<epics::pvData::PVStructure>, NDAttribute*) (v="Continuous", this=0x7fac140025f0)
> 
>     at /corvette/usr/local/epics-devel/base-7.0.2/include/pv/pvData.h:399
> 
> #5  0x00000000006cbf41 in NTNDArrayConverter::fromStringAttribute(std::tr1::shared_ptr<epics::pvData::PVStructure>, NDAttribute*) (this=this@entry=0x2fb0130, dest=
> 
>     std::tr1::shared_ptr (count 3, weak 1) 0x7fac140020b0, src=src@entry=0x7fabf0001620) at ../ntndArrayConverter.cpp:543
> 
> #6  0x00000000006ccc62 in NTNDArrayConverter::fromAttributes(NDArray*) (this=this@entry=0x2fb0130, src=src@entry=0x7fac94001270) at ../ntndArrayConverter.cpp:589
> 
> #7  0x00000000006cf38d in NTNDArrayConverter::fromArray(NDArray*) (this=0x2fb0130, src=src@entry=0x7fac94001270) at ../ntndArrayConverter.cpp:240
> 
> #8  0x000000000066c578 in NTNDArrayRecord::update(NDArray*) (this=0x2fad910, pArray=0x7fac94001270) at ../NDPluginPva.cpp:85
> 
> #9  0x000000000066c6ad in NDPluginPva::processCallbacks(NDArray*) (this=0x2f6c2a0, pArray=0x7fac94001270) at ../NDPluginPva.cpp:124
> 
> #10 0x000000000066f476 in NDPluginDriver::processTask() (this=0x2f6c2a0) at ../NDPluginDriver.cpp:524
> 
> #11 0x00000000012ac7f9 in epicsThreadCallEntryPoint(void*) (pPvt=0x2f6aff0) at ../../src/osi/epicsThread.cpp:83
> 
> #12 0x00000000012b226c in start_routine (arg=0x2f6aeb0) at ../../src/osi/os/posix/osdThread.c:403
> 
> #13 0x00007fad6ff53e25 in start_thread () at /lib64/libpthread.so.0
> 
> #14 0x00007fad6ee0cbad in clone () at /lib64/libc.so.6
> 
>  
> 
> This is base 7.0.2.2 on linux-x86_64.
> 
>  
> 
> Any idea why this is crashing?

I first suspect static cast in NTNDArrayConverter::fromStringAttribute()

https://github.com/areaDetector/ADCore/blob/44b3a9b62e65f8a8bfb180292f77d08a5e2c4fdd/ADApp/ntndArrayConverterSrc/ntndArrayConverter.cpp#L535-L544

From the logic, this code will break if the union already contains
something which isn't a PVString.

Assuming that the value should always be stored as a string (as opposed
to attempting a conversion).  Maybe change to something like:

> std::vector<char> value(attrDataSize); // same as malloc(), with auto-free()
> src->getValue(attrDataType, &value[0], attrDataSize);
>
> PVUnionPtr destUnion(dest->getSubFieldT<PVUnion>("value")); // note the added T
> PVStringPtr valueFld(destUnion->get<PVString>());
> if(!valueFld) {
>    valueFld = PVDC->createPVScalar<PVString>();
>    destUnion->put(valueFld);
> }
> value->put(value);

Replies:
RE: Crash in pvData Mark Rivers via Core-talk
References:
Crash in pvData Mark Rivers via Core-talk

Navigate by Date:
Prev: RE: Crash in pvData Mark Rivers via Core-talk
Next: RE: Crash in pvData Mark Rivers via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Crash in pvData Mark Rivers via Core-talk
Next: RE: Crash in pvData Mark Rivers via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 29 Jun 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·