sysrepo / sysrepo

YANG-based configuration and operational state data store for Unix/Linux applications
http://www.sysrepo.org
BSD 3-Clause "New" or "Revised" License
351 stars 233 forks source link

sysrepocfg coredump #3334

Closed reshad-equinix closed 2 months ago

reshad-equinix commented 3 months ago

I can reproduce this easily. I have some openconfig modules and a bunch of vendor modules installed and the core dump happens when I try to import an xml file.

sysrepo and libyang versions below.

commit 1773ced6f8301bf021a37b805be0a0864345d47c (HEAD -> devel, origin/devel)
Author: Michal Vasko <mvasko@cesnet.cz>
Date:   Tue Jul 2 15:27:35 2024 +0200

    VERSION bump to version 2.10.4

commit ae893eff9150b39e361f0017c2c8e75de5ef1be2 (HEAD -> devel, origin/devel)
Author: Michal Vasko <mvasko@cesnet.cz>
Date:   Tue Jul 2 08:35:40 2024 +0200

    xpath BUGFIX opaque node handling

    Fixes #2263
(gdb) run --import=basecfg.xml 
Starting program: /usr/local/bin/sysrepocfg --import=basecfg.xml
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007f2fb47d14c1 in lyd_validate_node_when (tree=0x5615a9582200, node=0x5615aa4f1690, schema=0x0, xpath_options=0, disabled=0x7ffc45b8a218) at /opt/dev/libyang/src/validation.c:185
185             schema = schema->parent;
(gdb) print schema
$1 = (const struct lysc_node *) 0x0
(gdb) bt
#0  0x00007f2fb47d14c1 in lyd_validate_node_when (tree=0x5615a9582200, node=0x5615aa4f1690, schema=0x0, xpath_options=0, disabled=0x7ffc45b8a218) at /opt/dev/libyang/src/validation.c:185
#1  0x00007f2fb47d17f1 in lyd_validate_unres_when (tree=0x7ffc45b8a398, mod=0x5615a97e9590, node_when=0x7ffc45b8a3e0, val_opts=33, xpath_options=0, node_types=0x7ffc45b8a3c0, 
    diff=0x7ffc45b8a520) at /opt/dev/libyang/src/validation.c:282
#2  0x00007f2fb47d1c20 in lyd_validate_unres (tree=0x7ffc45b8a398, mod=0x5615a97e9590, data_type=LYD_TYPE_DATA_YANG, node_when=0x7ffc45b8a3e0, when_xp_opts=0, node_types=0x7ffc45b8a3c0, 
    meta_types=0x7ffc45b8a3d0, ext_node=0x7ffc45b8a3f0, ext_val=0x7ffc45b8a400, val_opts=33, diff=0x7ffc45b8a520) at /opt/dev/libyang/src/validation.c:368
#3  0x00007f2fb47d6249 in lyd_validate (tree=0x7ffc45b8a610, module=0x5615a97e9590, ctx=0x5615a95a6a00, val_opts=33, validate_subtree=1 '\001', node_when_p=0x7ffc45b8a3e0, 
    node_types_p=0x7ffc45b8a3c0, meta_types_p=0x7ffc45b8a3d0, ext_node_p=0x7ffc45b8a3f0, ext_val_p=0x7ffc45b8a400, diff=0x7ffc45b8a520) at /opt/dev/libyang/src/validation.c:1871
#4  0x00007f2fb47d6824 in lyd_validate_module (tree=0x7ffc45b8a610, module=0x5615a97e9590, val_opts=33, diff=0x7ffc45b8a520) at /opt/dev/libyang/src/validation.c:1915
#5  0x00007f2fb485ecfe in sr_lyd_validate_module (data=0x7ffc45b8a610, mod=0x5615a97e9590, options=33, diff=0x7ffc45b8a520) at /opt/dev/sysrepo/src/ly_wrap.c:584
#6  0x00007f2fb4870bf0 in sr_modinfo_validate (mod_info=0x7ffc45b8a600, mod_state=516, finish_diff=1) at /opt/dev/sysrepo/src/modinfo.c:2881
#7  0x00007f2fb4845936 in sr_changes_notify_store (mod_info=0x7ffc45b8a600, session=0x5615a9fe7260, timeout_ms=5000, cb_err_info=0x7ffc45b8a5f8) at /opt/dev/sysrepo/src/sysrepo.c:3820
#8  0x00007f2fb4846406 in _sr_replace_config (session=0x5615a9fe7260, ly_mod=0x0, src_config=0x7ffc45b8a658, timeout_ms=5000) at /opt/dev/sysrepo/src/sysrepo.c:4072
#9  0x00007f2fb4846668 in sr_replace_config (session=0x5615a9fe7260, module_name=0x0, src_config=0x0, timeout_ms=5000) at /opt/dev/sysrepo/src/sysrepo.c:4129
#10 0x00005615a8ba3548 in ?? ()
#11 0x0000000000000001 in ?? ()
#12 0x00000000b48f4000 in ?? ()
#13 0x0000000000000000 in ?? ()
(gdb) 
michalvasko commented 3 months ago

Okay, could you please share the YANG files and the data file? If they are not public, please email them to me.

michalvasko commented 2 months ago

Okay, should be fixed in the latest libyang devel.

reshad-equinix commented 2 months ago

Confirming that I don't see the crash anymore, thanks for the quick fix @michalvasko ! This can be closed.

I am running into config validation issues, but I suspect this could be because I am not installing all the required yang (errors in the yang).

michalvasko commented 2 months ago

I am running into config validation issues, but I suspect this could be because I am not installing all the required yang (errors in the yang).

If not, create another issue.