Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault after referring a freed-up node #122

Open
Unniboy opened this issue Sep 4, 2024 · 0 comments
Open

Segmentation fault after referring a freed-up node #122

Unniboy opened this issue Sep 4, 2024 · 0 comments

Comments

@Unniboy
Copy link

Unniboy commented Sep 4, 2024

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"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant