libyang icon indicating copy to clipboard operation
libyang copied to clipboard

Segmentation fault when use lyd_new_path

Open NextLitete opened this issue 8 months ago • 1 comments

When I use the lyd_new_path interface of libyang2, there is a certain probability that the program will crash, and the corresponding stack information is as follows:

Thread 102 "tNCSess02" received signal SIGSEGV, Segmentation faultwarning: could not convert 'si_code' from the host encoding (UTF-8) to UTF-32.
This normally should not happen, please file a bug report.
.
[Switching to Thread 0xd98a0b40 (LWP 114432)]
0xf196780c in lysc_ext_instance_free (ctx=0xd989ed28, ext=0xd9242fd0) at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/tree_schema_free.c:664
664     /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/tree_schema_free.c: No such file or directory.
(gdb) bt
#0  0xf196780c in lysc_ext_instance_free (ctx=0xd989ed28, ext=0xd9242fd0) at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/tree_schema_free.c:664
#1  0xf1968a44 in lysc_type_free (ctx=0xd989ed28, type=0xd94cae88) at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/tree_schema_free.c:935
#2  0xf18fd9d4 in ly_path_predicates_free (ctx=0xeb564a40, predicates=0xd8553fd8) at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/path.c:1456
#3  0xf18fdab8 in ly_path_free (ctx=0xeb564a40, path=0xd8551900) at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/path.c:1477
#4  0xf191f54b in lyd_new_path_ (parent=0x0, ctx=0xeb564a40, ext=0x0, path=0xd854cdf0 "/netconf_sample:employee", value=0x0, value_len=0, value_type=LYD_ANYDATA_STRING, options=4,
    new_parent=0xd989eeb0, new_node=0x0) at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/tree_data_new.c:1811
#5  0xf191f78d in lyd_new_path (parent=0x0, ctx=0xeb564a40, path=0xd854cdf0 "/netconf_sample:employee", value=0x0, options=4, node=0xd989eeb0)
    at /usr1/OBL/ubp/utas/build/superbuild/__build/opensource/libyang/src/tree_data_new.c:1834

yang model:

  leaf-list employee {
    type string;
    min-elements 1;
  }

node path: /netconf_sample:employee

The version of libyang2 I use is closest to version 2.1.148.

Please confirm whether this issue has been fixed. If it has been fixed, please tell me in which version it was fixed or provide me with the relevant code. Thanks a lot!

NextLitete avatar Jun 16 '25 02:06 NextLitete

It is likely the issue has been fixed but I cannot guarantee it, have not seen such a problem before. So, ideally, if you could provide a simple standalone reproducer off the problem, should not be too difficult to write in this case, thanks.

michalvasko avatar Jun 16 '25 08:06 michalvasko