Skip to content

Segmentation fault after referring a freed-up node #122

Open
@Unniboy

Description

@Unniboy

Using the example in README, there are at least 2 ways to hit segmentation fault, using v3.0.2.
Requesting a fix or guide towards proper usage if the below seems incorrect.
Intention is to delete nodes based on some conditions.

>>> import libyang
>>> ctx = libyang.Context()
>>> module = ctx.parse_module_str('''
module example {
  namespace "urn:example";
  prefix "ex";
  container data {
    list interface {
      key name;
      leaf name {
        type string;
      }
      leaf address {
        type string;
      }
    }
    leaf hostname {
      type string;
    }
  }
}
''')
>>> node = module.parse_data_dict({
    'data': {
        'hostname': 'foobar',
        'interface': [
            {'name': 'eth0', 'address': '1.2.3.4/24'},
            {'name': 'lo', 'address': '127.0.0.1'},
        ],
    },
})
>>> nodes = list(node.find_all("/example:data"))
>>> nodes[0].free(with_siblings=False)
>>> print(node.print_mem('json', pretty=True)) # OR print(node.find_path("/example:data"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions