libyang will coredump when call plugin->store ,because plugin is null
stack:
hread 101 "tNCSess01" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xed0adb40 (LWP 4638)]
0xf2e8ec44 in union_store_type (ctx=0xec960dd8, type=0xd97942f8, subvalue=0xed30ba40, resolve=0 '\000', ctx_node=0x0, tree=0x0, unres=0x0, err=0xed0ac6a0)
at /usr1/OBL/ubp/open_source/libyang/src/plugins_types/union.c:182
182 /usr1/OBL/ubp/open_source/libyang/src/plugins_types/union.c: No such file or directory.
(gdb) bt
#0 0xf2e8ec44 in union_store_type (ctx=0xec960dd8, type=0xd97942f8, subvalue=0xed30ba40, resolve=0 '\000', ctx_node=0x0, tree=0x0, unres=0x0, err=0xed0ac6a0)
at /usr1/OBL/ubp/open_source/libyang/src/plugins_types/union.c:182
#1 0xf2e8ee08 in union_find_type (ctx=0xec960dd8, types=0xec9fe718, subvalue=0xed30ba40, resolve=0 '\000', ctx_node=0x0, tree=0x0, type_idx=0x0, unres=0x0,
err=0xed0ac6a0) at /usr1/OBL/ubp/open_source/libyang/src/plugins_types/union.c:236
#2 0xf2e8f1fc in lyplg_type_store_union (ctx=0xec960dd8, type=0xec9fc8d0, value=0xdc1cd819, value_len=5, options=0, format=LY_VALUE_XML, prefix_data=0xed303e30,
hints=511, ctx_node=0xd97e0808, storage=0xed0ac6ac, unres=0x0, err=0xed0ac6a0) at /usr1/OBL/ubp/open_source/libyang/src/plugins_types/union.c:347
#3 0xf2dafe9c in lys_value_validate (ctx=0x0, node=0xd97e0808, value=0xdc1cd819 "19.99</limit>\n </config>\n </edit-config>\n</rpc>", value_len=5,
format=LY_VALUE_XML, prefix_data=0xed303e30) at /usr1/OBL/ubp/open_source/libyang/src/tree_data_common.c:469
#4 0xf2dbb87e in lydxml_data_check_opaq (lydctx=0xed30a9c0, snode=0xed0ac808) at /usr1/OBL/ubp/open_source/libyang/src/parser_xml.c:392
#5 0xf2dbbf5c in lydxml_subtree_snode (lydctx=0xed30a9c0, parent=0x0, prefix=0x0, prefix_len=0,
name=0xdc1cd7e0 "limit xmlns=\"urn:ietf:params:xml:ns:yang:netconf_sample\">19.99</limit>\n </config>\n </edit-config>\n</rpc>", name_len=5, snode=0xed0ac808,
ext=0xed0ac80c) at /usr1/OBL/ubp/open_source/libyang/src/parser_xml.c:599
#6 0xf2dbc0f3 in lydxml_subtree_r (lydctx=0xed30a9c0, parent=0x0, first_p=0xed0ac8d8, parsed=0x0) at /usr1/OBL/ubp/open_source/libyang/src/parser_xml.c:658
#7 0xf2dbca2a in lydxml_subtree_r (lydctx=0xed30a9c0, parent=0xed302660, first_p=0xed302680, parsed=0x0) at /usr1/OBL/ubp/open_source/libyang/src/parser_xml.c:838
#8 0xf2dbc710 in lydxml_subtree_r (lydctx=0xed30a9c0, parent=0x0, first_p=0xed0acab4, parsed=0xed0acad0) at /usr1/OBL/ubp/open_source/libyang/src/parser_xml.c:777
#9 0xf2dbefc3 in lyd_parse_xml_netconf (ctx=0xec960dd8, ext=0x0, parent=0x0, first_p=0xed0acab4, in=0xed302478, parse_opts=196608, val_opts=0,
data_type=LYD_TYPE_RPC_NETCONF, envp=0xed0acab8, parsed=0xed0acad0, lydctx_p=0xed0acab0) at /usr1/OBL/ubp/open_source/libyang/src/parser_xml.c:1763
#10 0xf2da6bb0 in lyd_parse_op_ (ctx=0xec960dd8, ext=0x0, parent=0x0, in=0xed302478, format=LYD_XML, data_type=LYD_TYPE_RPC_NETCONF, tree=0xed0acb5c, op=0xed0acb60)
at /usr1/OBL/ubp/open_source/libyang/src/tree_data.c:332
#11 0xf2da6f53 in lyd_parse_op (ctx=0xec960dd8, parent=0x0, in=0xed302478, format=LYD_XML, data_type=LYD_TYPE_RPC_NETCONF, tree=0xed0acb5c, op=0xed0acb60)
at /usr1/OBL/ubp/open_source/libyang/src/tree_data.c:425
module:
leaf limit{
description "Number to allow";
type union{
type uint16{
range "0..100";
}
type int32;
type enumeration{
enum zero{
description "No limit";
}
enum one{
description "one limit";
}
enum two{
description "two limit";
}
}
type union {
type int8;
type boolean;
type empty;
type leafref {
path "/book/borrow_times";
}
type enumeration {
enum "unbounded";
}
}
type base_decimal64_type;
}
}
message:
<edit-config>
<target>
<running/>
</target>
<config>
<limit xmlns="urn:ietf:params:xml:ns:yang:netconf_sample">19.99</limit>
</config>
</edit-config>
The problem that no value is assigned to the plugin pointer when leafref is nested in union during compilation is solved.
It should be assigned the pointer value which is the plugin pointer of leafref, at lys_compile_type_union:1628
Of course, that's a personal suggestion. Please, help. Thanks!
What libyang version are you using? Please try it with the latest release or the devel branch and if you still manage to reproduce it, please mention the exact steps of doing so, with all the YANG and XML files needed attached.
The version we use is "version-2.1.30". we can not reproduce this bug in latest version because we have embed version-2.1.30 into our code reposity. It is very hard for us to update the version in our code repository.
plus:
we have provided yang module and xml in this post
I am not able to reproduce it in the current version meaning it has been fixed. What else do you expect me to do, to find the exact commit that fixed it? I would just have to try to find any relevant commits and test the specific revisions whether they fix this, you can do that, too. Nothing else for me to do.