CESNET / libyang

YANG data modeling language library
BSD 3-Clause "New" or "Revised" License
365 stars 292 forks source link

libyang crash when parsing rpc error containing yuma tools namespace #2191

Open g0wtham opened 7 months ago

g0wtham commented 7 months ago

Hi All,

I am facing a crash issue with libyang where it not able to parse the rpc-reply from the client which has the yuma tools name space embedded in the rpc-reply msg, can someone please tell me how to fix the libyang crash issue.

The BT of the crash looks like below:

#0  0x00007f3f250b9acf in raise () from /usr/lib64/libc.so.6
No symbol table info available.
#1  0x00007f3f2508cea5 in abort () from /usr/lib64/libc.so.6
No symbol table info available.
#2  0x00007f3f2508cd79 in __assert_fail_base.cold.0 () from /usr/lib64/libc.so.6
No symbol table info available.
#3  0x00007f3f250b2426 in __assert_fail () from /usr/lib64/libc.so.6
No symbol table info available.
#4  0x00007f3f25fab4e0 in lyd_insert_node (parent=0x7f3ee0024690, first_sibling_p=0x0, node=0x0, last=1 '\001')
    at /workspace/rhel-build/open-source/libyang/src/tree_data.c:2550
        anchor = 0xe8004cc0
        first_sibling = 0x7f3f0638bfc8
        __PRETTY_FUNCTION__ = "lyd_insert_node"
#5  0x00007f3f25fb7ced in lydxml_env_netconf_rpc_reply_error_info (xmlctx=0x7f3ee001ea70, parent=0x7f3ee0024690)
    at /workspace/rhel-build/open-source/libyang/src/parser_xml.c:1091
        r = LY_SUCCESS
        child = 0x0
        iter = 0x7f3ee8004cc0
        ns = 0x7f3ee000e600
        no_dup = 0 '\000'
        __PRETTY_FUNCTION__ = "lydxml_env_netconf_rpc_reply_error_info"
 6  0x00007f3f25fb82b1 in lydxml_env_netconf_rpc_reply_error (xmlctx=0x7f3ee001ea70, parent=0x7f3ee0069f60)
    at /workspace/rhel-build/open-source/libyang/src/parser_xml.c:1225
        r = LY_SUCCESS
        child = 0x7f3ee0024690
        iter = 0x0
        val = 0x7f3ee80443c0 "error"
        no_dup = 1 '\001'
        __PRETTY_FUNCTION__ = "lydxml_env_netconf_rpc_reply_error"
#7  0x00007f3f25fb86ff in lydxml_env_netconf_reply (xmlctx=0x7f3ee001ea70, envp=0x7f3f0638be10, int_opts=0x7f3f0638bd84,
    close_elem=0x7f3f0638bd80) at /workspace/rhel-build/open-source/libyang/src/parser_xml.c:1344
        rc = LY_SUCCESS
        r = LY_SUCCESS
--Type <RET> for more, q to quit, c to continue without paging--c
        child = 0x7f3ee0069f60
        parsed_elem = 0x0
        __PRETTY_FUNCTION__ = "lydxml_env_netconf_reply"
#8  0x00007f3f25fb8ae8 in lyd_parse_xml (ctx=0x7f3ee800d470, ext=0x0, parent=0x7f3ee0067780, first_p=0x7f3f0638be18, in=0x7f3ee0069e80, parse_opts=327680, val_opts=0, data_type=LYD_TYPE_REPLY_NETCONF, envp=0x7f3f0638be10, parsed=0x7f3f0638be20, lydctx_p=0x7f3f0638be38) at /workspace/rhel-build/open-source/libyang/src/parser_xml.c:1423
        rc = LY_SUCCESS
        lydctx = 0x7f3ee0023620
        i = 0
        int_opts = 0
        close_elem = 0
        parsed_data_nodes = 0 '\000'
        __PRETTY_FUNCTION__ = "lyd_parse_xml"
        __func__ = "lyd_parse_xml"
#9  0x00007f3f25fa4115 in lyd_parse_op_ (ctx=0x7f3ee800d470, ext=0x0, parent=0x7f3ee0067780, in=0x7f3ee0069e80, format=LYD_XML, data_type=LYD_TYPE_REPLY_NETCONF, tree=0x7f3f0638bfa8, op=0x0) at /workspace/rhel-build/open-source/libyang/src/tree_data.c:558
        rc = LY_SUCCESS
        lydctx = 0x0
        parsed = {size = 0, count = 0, {dnodes = 0x0, snodes = 0x0, objs = 0x0}}
        first = 0x0
        envp = 0x7f3ee0069ed0
        i = 3758509704
        parse_opts = 327680
        val_opts = 0
        __func__ = "lyd_parse_op_"
#10 0x00007f3f25fa4465 in lyd_parse_op (ctx=0x0, parent=0x7f3ee0067780, in=0x7f3ee0069e80, format=LYD_XML, data_type=LYD_TYPE_REPLY_NETCONF, tree=0x7f3f0638bfa8, op=0x0) at /workspace/rhel-build/open-source/libyang/src/tree_data.c:625
        __func__ = "lyd_parse_op"
#11 0x00007f3f2655e51f in recv_reply (session=0x7f3ee8004cc0, timeout=10000, op=0x7f3ee0067780, msgid=274, envp=0x7f3f0638bfa8) at /workspace/rhel-build/open-source/libnetconf2/src/session_client.c:1842
        lyrc = 4109878016
        msg = 0x7f3ee0069e80
        ret = NC_MSG_REPLY
        __PRETTY_FUNCTION__ = "recv_reply"
#12 0x00007f3f2655ecfe in nc_recv_reply (session=0x7f3ee8004cc0, rpc=0x7f3ed80029b0, msgid=274, timeout=10000, envp=0x7f3f0638bfa8, op=0x7f3f0638bfb0) at /workspace/rhel-build/open-source/libnetconf2/src/session_client.c:2050

The rpc reply from the client is,

image

Thanks, P.Gowtham

michalvasko commented 7 months ago

I have briefly tested it and got the correct error

Unexpected child element "error-number" of "rpc-error".

because custom error information is supposed to be stored in error-info. But it should definitely not crash, what libyang version are you using?

g0wtham commented 7 months ago

Thanks @michalvasko for the quick response, the version of libyang we are using is v2.0.88 of revision "dd349cf0fb2c6ae91fae72e5bc07d994057cf2ef"

michalvasko commented 7 months ago

Okay, that is way too old and you are lucky if this is the first issue you encountered.

g0wtham commented 7 months ago

@michalvasko can you let me know to which version of libyang should I upgrade so that issue might be not seen

michalvasko commented 7 months ago

No, I would have to look for the exact version with a fix. Just grab the latest released version and you should be fine (2.1.148).

g0wtham commented 7 months ago

will update and check if the issue exists or not