Open
Description
Requesting help to get past the segmentation fault.
libyang: v2.1.148
libyang-python: v2.8.4
The following set of operations result in segmentation fault. Intermediate unrelated steps modifying dtree(play_tree after loading classroom) could be a premonition of the eventual segmentation fault.
Couldn't see anything wrong with the yangs themselves, given dtree was generated.
>>> import libyang
>>> ctx = libyang.Context('poc')
>>>
>>> play_mod= ctx.load_module('playroom')
>>> play_dict={'playroom-container':{'playroom-list': [{'name': 'dodge', 'play': 'gogogo'}]}}
>>> play_tree = play_mod.parse_data_dict(play_dict, validate=False)
>>>
>>> play_tree.print_dict()
{'playroom-container': {'playroom-list': [{'name': 'dodge', 'play': 'gogogo'}]}}
>>>
>>>
>>> class_mod= ctx.load_module('classroom')
>>>
>>>
>>> play_tree.print_dict()
{'playroom-container': {}}
>>>
>>>
>>> class_dict={'classroom-container': {'classroom-list': [{'name': 'grade5', 'teacher-present': True, 'shout': 'wohoo'}]}}
>>> class_tree = class_mod.parse_data_dict(class_dict, validate=False)
>>>
>>>
>>> class_tree.print_dict()
{'classroom-container': {'classroom-list': [{'name': 'grade5', 'teacher-present': True, 'shout': 'wohoo'}]}}
>>>
>>>
>>> play_tree.print_dict()
Segmentation fault
The yang definitions are as below:
module str-types {
namespace "http://str-types";
prefix "str-types";
typedef name-type {
type string;
}
grouping chaos {
leaf shout {
type name-type;
}
}
}
module playroom {
namespace "http://playroom";
prefix "playroom";
import str-types { prefix str-types; }
container playroom-container {
list playroom-list {
key "name";
leaf name {
type string;
}
leaf play {
type str-types:name-type;
}
}
}
}
module classroom {
namespace "http://classroom";
prefix "classroom";
import str-types { prefix str-types; }
container classroom-container {
list classroom-list {
key "name";
leaf name {
type string;
}
leaf teacher-present {
type boolean;
}
uses str-types:chaos {
when "not(./teacher-present) or ./teacher-present = 'false'";
}
leaf study {
when "../teacher-present and ../teacher-present = 'true'";
type str-types:name-type;
}
}
}
}
Metadata
Metadata
Assignees
Labels
No labels