CESNET / libyang

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

Device crashes when netconf payload is applied without proper namespace #2082

Open MoshikaKarthesan opened 1 year ago

MoshikaKarthesan commented 1 year ago

Hi , I applied a payload to delete config without including proper namespace. Device crashed with the below backtrace. Is it designed that way or should we return an error message describing that there is some issue with payload.

Versions:

libyang version v2.1.4 libsysrepo version v2.2.12 libssh version v0.9.0 libnetconf2 version v2.1.25 netopeer2 version v2.1.42

Applied payload: IGMP_delete.txt

Expected payload: IGMP_DEL.txt

Backtrace:

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007feaf3d25535 in __GI_abort () at abort.c:79
#2  0x00007feaf3d2540f in __assert_fail_base (fmt=0x7feaf3e86ee0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x7feaf408ef90 "!parent || !iter->schema || !parent->schema || (lysc_data_parent(iter->schema) == parent->schema)",
    file=0x7feaf408e630 "/home/debian/Latest_sysrepo/libyang/src/tree_data.c", line=2349, function=<optimized out>) at assert.c:92
#3  0x00007feaf3d33102 in __GI___assert_fail (
    assertion=0x7feaf408ef90 "!parent || !iter->schema || !parent->schema || (lysc_data_parent(iter->schema) == parent->schema)",
    file=0x7feaf408e630 "/home/debian/Latest_sysrepo/libyang/src/tree_data.c", line=2349, function=0x7feaf408f4f8 <__PRETTY_FUNCTION__.11309> "lyd_path_set")
    at assert.c:101
#4  0x00007feaf3f8f7ba in lyd_path_set (dnodes=0x7feaf0e8b6c8, pathtype=LYD_PATH_STD) at /home/debian/Latest_sysrepo/libyang/src/tree_data.c:2349
#5  0x00007feaf3f72833 in ly_vlog_build_path (ctx=0x55d1970b3b40, path=0x7feaf0e8a428) at /home/debian/Latest_sysrepo/libyang/src/log.c:608
#6  0x00007feaf3f72d46 in ly_vlog (ctx=0x55d1970b3b40, apptag=0x0, code=LYVE_REFERENCE, format=0x7feaf4090e25 "Unknown XML prefix \"%.*s\".")
    at /home/debian/Latest_sysrepo/libyang/src/log.c:662
#7  0x00007feaf3f9f318 in lydxml_metadata (lydctx=0x7feadc0031a0, sparent=0x55d1971b6600, meta=0x7feaf0e8a5f8)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:117
#8  0x00007feaf3fa0915 in lydxml_subtree_r (lydctx=0x7feadc0031a0, parent=0x7feadc0012c0, first_p=0x7feadc0012f8, parsed=0x0)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:657
#9  0x00007feaf3fa0fca in lydxml_subtree_r (lydctx=0x7feadc0031a0, parent=0x7feadc001240, first_p=0x7feadc001278, parsed=0x0)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:763
#10 0x00007feaf3fa0fca in lydxml_subtree_r (lydctx=0x7feadc0031a0, parent=0x0, first_p=0x7feaf0e8a928, parsed=0x0)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:763
#11 0x00007feaf3fa1370 in lydxml_subtree_r (lydctx=0x7feadc0031a0, parent=0x7feadc001e60, first_p=0x7feadc001e98, parsed=0x0)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:824
#12 0x00007feaf3fa0fca in lydxml_subtree_r (lydctx=0x7feadc0031a0, parent=0x0, first_p=0x7feaf0e8abf8, parsed=0x7feaf0e8ac00)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:763
#13 0x00007feaf3fa3660 in lyd_parse_xml (ctx=0x55d1970b3b40, ext=0x0, parent=0x0, first_p=0x7feaf0e8abf8, in=0x7feadc002630, parse_opts=196608, val_opts=0,
    data_type=LYD_TYPE_RPC_NETCONF, envp=0x7feaf0e8abf0, parsed=0x7feaf0e8ac00, subtree_sibling=0x0, lydctx_p=0x7feaf0e8ac18)
    at /home/debian/Latest_sysrepo/libyang/src/parser_xml.c:1674
#14 0x00007feaf3f89138 in lyd_parse_op_ (ctx=0x55d1970b3b40, ext=0x0, parent=0x0, in=0x7feadc002630, format=LYD_XML, data_type=LYD_TYPE_RPC_NETCONF,
    tree=0x7feadc002c10, op=0x7feadc002c18) at /home/debian/Latest_sysrepo/libyang/src/tree_data.c:321
#15 0x00007feaf3f8948d in lyd_parse_op (ctx=0x55d1970b3b40, parent=0x0, in=0x7feadc002630, format=LYD_XML, data_type=LYD_TYPE_RPC_NETCONF, tree=0x7feadc002c10,
    op=0x7feadc002c18) at /home/debian/Latest_sysrepo/libyang/src/tree_data.c:388
#16 0x00007feaf9139c42 in nc_server_recv_rpc_io (session=0x7feae4000f30, io_timeout=10, rpc=0x7feaf0e8ad18)
    at /home/debian/Latest_sysrepo/libnetconf2/src/session_server.c:1403
#17 0x00007feaf913ac94 in nc_ps_poll (ps=0x55d19721adf0, timeout=10, session=0x7feaf0e8ae90) at /home/debian/Latest_sysrepo/libnetconf2/src/session_server.c:1865
#18 0x000055d195793751 in worker_thread (arg=0x55d1970ad1b0) at /home/debian/Latest_sysrepo/netopeer2/src/main.c:990
#19 0x00007feaf9057fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#20 0x00007feaf3dfbeff in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
michalvasko commented 1 year ago

Yes, it works with the current versions of libyang but I cannot tell you which commit fixed it, that is not what we provide as part of the support.