Crash during findServers

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

Moderator: uasdkcpp

Post Reply
wim
Hero Member
Hero Member
Posts: 24
Joined: 13 Jul 2010, 15:20

Crash during findServers

Post by wim »

Hello Unified Automation,

I think there may be a bug in the SDK (or stack) related to the FindServers service:
If the UaClientSdk::ServiceSettings::callTimeout is put to 1000 msec, and there is no server running at the specified URL, then UaClientSdk::UaDiscovery::findServers sometimes crashes. It only seems to happen in Windows, not in Linux.

Here's a sample program to reproduce the crash:

Code: Select all

// discovery_crash.cpp

// STD
#include <iostream>
// SDK
#include "uabase/uaplatformlayer.h"
#include "uaclient/uaclientsdk.h"
#include "uaclient/uadiscovery.h"


int main(int /*argc*/, char* /*argv*/[])
{
    // initialize the SDK
    if(UaPlatformLayer::init() != 0)
    {
        std::cout << "The SDK could not be initialized!\n";
        return 1;
    }


    UaClientSdk::UaDiscovery        uaDiscovery;
    UaClientSdk::ServiceSettings    serviceSettings;
    UaString                        url("opc.tcp://localhost:4841");
    UaClientSdk::ClientSecurityInfo clientSecurityInfo;
    UaApplicationDescriptions       descriptions;

    // put the callTimeout to  500 msec --> BadTimeout but no crashes
    // put the callTimeout to 2000 msec --> BadCommunicationError but no crashes
    // put the callTimeout to 1000 msec --> mostly BadTimeouts, sometimes BadCommunicationErrors, after a while: crash
    serviceSettings.callTimeout = 1000;

    while (true)
    {
        UaStatus discoveryStatus = uaDiscovery.findServers(
                                serviceSettings,
                                url,
                                clientSecurityInfo,
                                descriptions);
        std::cout << "FindServers Status: " << discoveryStatus.toString().toUtf8() << "\n";
    }

    return 0;
}
Kind regards,

Wim

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

Re: Crash during findServers

Post by Support Team »

Hi wim,

Thank you very much for reporting this issue.

We are abel to reproduce this issue. It is located in the windows platform layer of the ANSI C stack. We got such an issue reported before but it was a very rare and random issue with a server trying to register with a non existing discovery server. Therefore it was difficult to reproduce and especially to find the reason. With your example it is very easy to reproduce now and we should be able to fix it now.

Best Regards,
Unified Automation Support Team

wim
Hero Member
Hero Member
Posts: 24
Joined: 13 Jul 2010, 15:20

Re: Crash during findServers

Post by wim »

Thanks a lot!

kind regards,

Wim

Post Reply