Segfault on server when using DCI push

Started by tolimanjo, April 05, 2023, 07:48:51 AM

Previous topic - Next topic

tolimanjo

Hi there,

I'm getting a segfault on server 4.3.3 (Debian) when using PushDCIData() in a transform script. If the DCI I'm pushing to has 'Save only changed values' enabled, then a segfault occurs.

I haven't been able to reproduce this behavior on a test platform, so can't rule out something else being the cause of the problem. Curiously, the fault only occurs after a restart of the server.

Thread 33 "$DATACOLL/WRK" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff04b0700 (LWP 8118)]
DCItem::processNewValue (this=0x7ffe2f3a7410, tmTimeStamp=tmTimeStamp@entry=1680668319, originalValue=originalValue@entry=0x7ffc8bcad844 L"20", updateStatus=0x7ffff04a9b97) at dcitem.cpp:698
698    dcitem.cpp: No such file or directory.
(gdb) bt
#0  DCItem::processNewValue (this=0x7ffe2f3a7410, tmTimeStamp=tmTimeStamp@entry=1680668319, originalValue=originalValue@entry=0x7ffc8bcad844 L"20", updateStatus=0x7ffff04a9b97) at dcitem.cpp:698
#1  0x00007ffff7c18dee in DataCollectionTarget::processNewDCValue (this=this@entry=0x7ffe2ef49010, dcObject=std::shared_ptr<DCObject> (use count 2, weak count 0) = {...}, currTime=currTime@entry=1680668319,
    itemValue=0x7ffc8bcad844 L"20", tableValue=std::shared_ptr<Table> (empty) = {...}) at /usr/include/c++/8/bits/shared_ptr_base.h:1018
#2  0x00007ffff7beb450 in F_PushDCIData (argc=<optimized out>, argv=0x7ffc8bc15400, ppResult=0x7ffff04a9c50, vm=0x7ffc8bc42000) at /usr/include/c++/8/bits/shared_ptr_base.h:614
#3  0x00007ffff7a20547 in NXSL_VM::callExternalFunction (stackItems=3, function=<optimized out>, this=0x7ffc8bc42000) at ../../include/nxsl_classes.h:201
#4  NXSL_VM::callExternalFunction (this=0x7ffc8bc42000, function=<optimized out>, stackItems=3) at vm.cpp:2675
#5  0x00007ffff7a24ea7 in NXSL_VM::execute (this=0x7ffc8bc42000) at vm.cpp:1411
#6  0x00007ffff7a297c8 in NXSL_VM::run (this=this@entry=0x7ffc8bc42000, args=..., globals=globals@entry=0x0, expressionVariables=expressionVariables@entry=0x0, constants=constants@entry=0x0, entryPoint=entryPoint@entry=0x0)
    at vm.cpp:391
#7  0x00007ffff7a29c42 in NXSL_VM::run (this=this@entry=0x7ffc8bc42000, argc=argc@entry=1, argv=argv@entry=0x7ffff04aa040, globals=globals@entry=0x0, expressionVariables=expressionVariables@entry=0x0, constants=constants@entry=0x0,
    entryPoint=0x0) at vm.cpp:321
#8  0x00007ffff7c10dca in DCTable::transform (this=this@entry=0x7ffe2f140610, value=std::shared_ptr<Table> (use count 2, weak count 0) = {...}) at ../../../include/nxsl_classes.h:1427
#9  0x00007ffff7c116e9 in DCTable::processNewValue (this=0x7ffe2f140610, timestamp=timestamp@entry=1680668319, value=std::shared_ptr<Table> (use count 2, weak count 0) = {...}, updateStatus=updateStatus@entry=0x7ffff04aa527)
    at dctable.cpp:357
#10 0x00007ffff7c18d9c in DataCollectionTarget::processNewDCValue (this=0x7ffe2ef49010, dcObject=std::shared_ptr<DCObject> (use count 2, weak count 0) = {...}, currTime=currTime@entry=1680668319,
    itemValue=itemValue@entry=0x7ffff04aad60 L"", tableValue=std::shared_ptr<Table> (use count 2, weak count 0) = {...}) at /usr/include/c++/8/bits/shared_ptr_base.h:1018
#11 0x00007ffff7be49c8 in DataCollector (dcObject=std::shared_ptr<DCObject> (use count 2, weak count 0) = {...}) at /usr/include/c++/8/bits/shared_ptr_base.h:762
#12 0x00007ffff7c22afa in __ThreadPoolExecute_SharedPtr_Wrapper<DCObject> (arg=0x7ffc8c000020) at ../../../include/nms_threads.h:990
#13 0x00007ffff794c21e in ProcessSerializedRequests (data=0x7ffc8c00b050) at tp.cpp:487
#14 0x00007ffff794c066 in WorkerThread (threadInfo=0x7fffeb5b15b0) at tp.cpp:199
#15 0x00007ffff794de4a in ThreadCreate_Wrapper_1<WorkerThreadInfo*> (context=0x7fffeb5b15c0) at ../../include/nms_threads.h:536
#16 0x00007ffff779ffa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#17 0x00007ffff6ec206f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)

Victor Kirhenshtein

Hi,

I was unable to reproduce it on my test system either. However, there is one path that could potentially lead to such crash. I've made changes to DCI value processing method, they will be included in upcoming patch release 4.3.4.

Best regards,
Victor

tolimanjo

Thanks for looking into that. 

I've worked around the problem for now, so will wait and see if the patch fixes it.

tolimanjo

Hi Victor,

Upgrading to 4.3.4 did indeed fix the PushDCIData() segfault problem I was seeing.

Thanks for your help.