Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opcuaShow() segfaults when matching record names #125

Closed
ralphlange opened this issue Sep 15, 2021 · 2 comments
Closed

opcuaShow() segfaults when matching record names #125

ralphlange opened this issue Sep 15, 2021 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ralphlange
Copy link
Member

Reported by @bkuner:

Description
Running opcuaShow() with a record name segfaults immediately.

Steps to reproduce the behavior:

  1. Setup server
  2. Create IOC database that contains myRecord connected to OPC UA
  3. Start IOC (connects successfully), run opcuaShow("myRecord")
  4. Boom:
box0>opcuaShow("LIOCV:setEG_DL")
[1]    17777 segmentation fault  ./st.cmd.SIOC3V

Setup:

  • OPC UA Support: 0.9.2
  • Platform: Debian
  • EPICS Base: 3.15.6
  • Client library: UA SDK 1.6.3
  • Server: Softing UaGate
@ralphlange
Copy link
Member Author

I can't reproduce on a similar system, using the client for the UA Example server:

iocInit
Starting iocInit
############################################################################
## EPICS R3.15.6
## EPICS Base built Sep 15 2021
############################################################################
OPC UA Client Device Support 0.10.0-dev (v0.9.2-2-ga5c1885); using Unified Automation C++ Client SDK v1.5.5-355
OPC UA: Autoconnecting sessions
OPC UA session OPC1: connection status changed from Disconnected to Connected
OPC UA session OPC1: connected as 'Anonymous' (sec-mode: None; sec-policy: None)
OPC UA session OPC1: WARNING - this session uses *** NO SECURITY ***
iocRun: All initialization complete
epics> dbgrep OPC:DSS:ai*
OPC:DSS:aidouble
OPC:DSS:aiint32
epics> opcuaShow OPC:DSS:ai*
item ns=2;s=Demo.Static.Scalar.Double record=OPC:DSS:aidouble state=up status=Good dataDirty=n context=SUB1@OPC1 sampling=250(-1) qsize=1(1) cqsize=3 discard=old timestamp=server bini=read output=n monitor=y registered=-(n)
item ns=2;s=Demo.Static.Scalar.Int32 record=OPC:DSS:aiint32 state=up status=Good dataDirty=n context=SUB1@OPC1 sampling=250(-1) qsize=1(1) cqsize=3 discard=old timestamp=server bini=read output=n monitor=y registered=-(n)
epics> opcuaShow OPC:DSS:aidouble
item ns=2;s=Demo.Static.Scalar.Double record=OPC:DSS:aidouble state=up status=Good dataDirty=n context=SUB1@OPC1 sampling=250(-1) qsize=1(1) cqsize=3 discard=old timestamp=server bini=read output=n monitor=y registered=-(n)

@ralphlange
Copy link
Member Author

@bkuner did some additional debugging:

RecordConnector::glob(const std::string &pattern)
{
    DBENTRY entry;
    long status;
    std::set<RecordConnector *> result;

    dbInitEntry(pdbbase, &entry);
    status = dbFirstRecordType(&entry);
    while (!status) {
        status = dbFirstRecord(&entry);
        while (!status) {
//DEBUG   

            char * s;
            status = dbFindField(&entry, "RTYP");
            if( ! status) s= dbGetString(&entry);
            printf("%ld: '%s'",status,s);
            status = dbFindField(&entry, "DTYP");
            if( ! status) s= dbGetString(&entry);
            printf("%ld: '%s'",status,s);

//DEBUG END
            if (!(dbFindField(&entry, "RTYP") || strcmp(dbGetString(&entry), "opcuaItem"))
               || !(dbFindField(&entry, "DTYP") || strcmp(dbGetString(&entry), "OPCUA"))) {

and found that the code segfaults when coming across a seq record.

That delivered the crucial hint:
The seq record has a DTYP field (in dbCommon) that is never set. dbFindField() finds it nevertheless. However, the code in dbGetEntry() will return NULL for DTYP (as the DTYP menu of the seq record has no choices).

@ralphlange ralphlange self-assigned this Sep 16, 2021
@ralphlange ralphlange added the bug Something isn't working label Sep 16, 2021
@ralphlange ralphlange added this to the 0.10 pre-release milestone Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant