Bug in monitoring when sampling interval is 0, toolkit 1.3.3

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

Moderator: uasdkcpp

Post Reply
schlenk
Sr. Member
Sr. Member
Posts: 10
Joined: 04 Jul 2013, 14:01

Bug in monitoring when sampling interval is 0, toolkit 1.3.3

Post by schlenk »

Dear All,

I believe I've found a bug which is very specific to monitoring items with revised sampling interval equal to 0.

Conditions:
- toolkit 1.3.3
- problem visible both with Linux and Windows
- configuring the server for allowing only sampling interval = 0 :
ServerConfig.xml:
<!--Minimum sample interval supported by the server-->
<MinSupportedSampleRate>0</MinSupportedSampleRate>

<!--Settings for the sampling engine.-->
<AvailableSamplingRates>
<SamplingRate>0</SamplingRate>
</AvailableSamplingRates>

Bug:
- toolkit writes to incorrect memory locations, destroying its own data or user supplied data
- visual symptoms depend on particular server used. I have two servers (two different software projects):
-- with more complex server the subscriptions fail to be created and user's memory is garbaged
-- with simple server the server quits with failed assertion:

Server: .../src/uaserver/uaservercpp/coremodule/samplingengine.cpp:226: void SamplingEngine::removeItemFromSampling(SamplingExecution*, OpcUa_Int32): Assertion `false' failed.
Aborted (core dumped)


We have run more complex server with valgrind and here is what it says:


***************************************************
Press CTRL-C to shutdown server
***************************************************
==17289== Thread 3:
==17289== Invalid read of size 4
==17289== at 0x66812D: IOManagerUaNodeJob::executeMonitorBegin() (in /opt/OpcUaCanOpenServer/bin/OpcUaCanOpenServer)
==17289== by 0x71801F: UaJobThread::run() (in /opt/OpcUaCanOpenServer/bin/OpcUaCanOpenServer)
==17289== by 0x4C7304C: InternalThreadMain (in /opt/OpcUaToolkit-1.3.3/lib/libuastack.so)
==17289== by 0x4CE0889: pthread_start (in /opt/OpcUaToolkit-1.3.3/lib/libuastack.so)
==17289== by 0x3551E079D0: start_thread (pthread_create.c:301)
==17289== by 0x3551AE89DC: clone (clone.S:115)
==17289== Address 0xa0bc9b0 is 0 bytes after a block of size 0 alloc'd
==17289== at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==17289== by 0x667F8F: IOManagerUaNodeJob::executeMonitorBegin() (in /opt/OpcUaCanOpenServer/bin/OpcUaCanOpenServer)
==17289== by 0x71801F: UaJobThread::run() (in /opt/OpcUaCanOpenServer/bin/OpcUaCanOpenServer)
==17289== by 0x4C7304C: InternalThreadMain (in /opt/OpcUaToolkit-1.3.3/lib/libuastack.so)
==17289== by 0x4CE0889: pthread_start (in /opt/OpcUaToolkit-1.3.3/lib/libuastack.so)
==17289== by 0x3551E079D0: start_thread (pthread_create.c:301)
==17289== by 0x3551AE89DC: clone (clone.S:115)


Importtant point: when instead of sampling interval = 0 we use anything else e.g. 1000, the problem is not visible.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Bug in monitoring when sampling interval is 0, toolkit 1

Post by Support Team »

Hi,

This is an invalid configuration and it is not properly handled in the SDK.

The idea of sampling is that the server checks in a client requested time interval (SamplingInterval) if the value of a variable was changed. The SamplingInterval '0' is a special one that cannot be used if the value must be checked for change (polling). This value makes only sense if the value changes are delivered as change events or if the values are updated in the UaVariable class with setValue().

Therefore the SamplingInterval 0 may be allowed but is only used for special variables and the SDK needs at least one (or more) SamplingInterval > 0 that is used for polled value change checks.

We will make sure that a SamplingInterval > 0 is applied in addition to 0 if the SamplingInterval list contains only 0 as entry.

Best Regards,
Unified Automation Support Team

schlenk
Sr. Member
Sr. Member
Posts: 10
Joined: 04 Jul 2013, 14:01

Re: Bug in monitoring when sampling interval is 0, toolkit 1

Post by schlenk »

Dear Sir/Madam,

just to comment on that.

The fact that we used just sampling interval of 0 was fully intentional as we are interested only in no-sampling mode of operation. All variables created by us are updated on-change and we dont intend to have anything polled/sampled. I guess then that this non-zero sampling is needed for that standard variables that the toolkit creates? ("Server" node in NS1, etc).

Thanks for confirming that this will be fixed.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Bug in monitoring when sampling interval is 0, toolkit 1

Post by Support Team »

Hi,

You are right, the non zero sampling is necessary for variables that require polling. Even if all of your variables are change based, there are a few diagnostic variables in namespace 1 which are based on counters in C++ class variables and they require polling.

But we made sure that the change based variable are just using 0 if nothing else is configured. This should cover your use case.

Best Regards,
Unified Automation Support Team

Post Reply