Segfault in UaStatus destructor + Issues w/ Status Codes

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
bryankim96
Jr. Member
Jr. Member
Posts: 2
Joined: 13 Nov 2018, 18:56

Segfault in UaStatus destructor + Issues w/ Status Codes

Post by bryankim96 »

In my use-case, I have a server containing custom objects which implement some methods. I connect to the server with a client and then use UaSession.call() to call the methods (synchronously) from the client. The called method appears to execute correctly on the server, but immediately afterwards I get a segmentation fault in the destructor for UaStatus.

Here is the backtrace from gdb:

#0 0x0000000000a47f41 in UaStringPrivate::release() ()
#1 0x00000000008e68db in UaDiagnosticInfo::release() ()
#2 0x00000000008e6a1a in UaStatus::~UaStatus() ()
#3 0x000000000074fa8d in OpcUa::MethodCallJob::execute() ()
#4 0x0000000000a52f10 in UaJobThread::run() ()
#5 0x00007ffff7afa588 in InternalThreadMain () at /home/user/pSCT-alignment/sdk/cmake/../lib64/libuastack.so
#6 0x00007ffff7b06e37 in pthread_start () at /home/user/pSCT-alignment/sdk/cmake/../lib64/libuastack.so
#7 0x00007ffff788bdd5 in start_thread () at /lib64/libpthread.so.0
#8 0x00007ffff0df6ead in clone () at /lib64/libc.so.6

I've been trying to work through things w/ gdb and Valgrind, but I've been having a very hard time because it appears to be occurring in a separate thread, making the backtrace not very informative... Does anyone have a vague idea as to what I could be doing that would cause problems with the destructor for a UaStatus?

I also had one other question about Status Codes:

Can anyone provide some pointers for interpreting status codes? I've read the OPC UA spec and seen the list of spec-defined status codes here: https://opcfoundation.org/UA/schemas/1. ... usCodes.cs.

In my client, at some point I call UaSession.call(). When I test the resulting UaStatus status I find that it is bad (status.isBad() is true). I then attempted to print only the code part of the status code as a string with UaStatusCode(status.code()).toString().toUtf8(). The first thing that is strange to me is that documentation for UaStatusCode.toString() states that it returns "The symbolic name for the passed status code", while what I see is the raw code in hex: 0x812e0000. The other thing I noticed was that this code doesn't seem to be in the listed specification.

Am I doing something wrong? If so, how can I get an interpret-able value for the status code that I can use to debug?

Post Reply