ydk-gen icon indicating copy to clipboard operation
ydk-gen copied to clipboard

Python crushes while traversing entities to the top level

Open ygorelik opened this issue 4 years ago • 0 comments

Current Behavior

Getting python crush (segmentation fault) while traversing entities to the top level entity.

Steps to Reproduce

Execute the following script:

#!/usr/bin/env python
#
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_oper as xr_ipv4_bgp_oper

import logging

def enable_logging(level):
    log = logging.getLogger('ydk')
    log.setLevel(level)
    handler = logging.StreamHandler()
    formatter = logging.Formatter(
            "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)

def build_bgp_instance_obj():
    bgp_oper_obj = xr_ipv4_bgp_oper.Bgp()

    bgp_oper_instance_list_obj = xr_ipv4_bgp_oper.Bgp.Instances.Instance()
    bgp_oper_instance_list_obj.instance_name = 'default'
    bgp_oper_obj.instances.instance.append(bgp_oper_instance_list_obj)
    return bgp_oper_instance_list_obj

if __name__ == '__main__':

    enable_logging(logging.INFO)

    provider = NetconfServiceProvider(
        address='sbx-iosxr-mgmt.cisco.com',
        port=10000,
        username='admin',
        password='C1sco12345')

    crud = CRUDService()

    bgp_instance_obj = build_bgp_instance_obj()

    bgp_oper = crud.read(provider, bgp_instance_obj)

Getting the following output:

/Users/ygorelik/venv/bin/python /Users/ygorelik/ydk-gen/scripts/community/xr_bgp_oper.py
2020-11-03 10:02:39,216 - ydk - INFO - Path where models are to be downloaded: /Users/ygorelik/.ydk/sbx-iosxr-mgmt.cisco.com
2020-11-03 10:02:39,250 - ydk - INFO - Connected to sbx-iosxr-mgmt.cisco.com on port 10000 using ssh with timeout of -1

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

Script debugging showed that Python crushes in function ydk.entity_utils._traverse_to_top_entity:

def _traverse_to_top_entity(entity):
    while entity.parent is not None:
        entity = entity.parent    # crushes on execution of this line
    return entity

Note. No issues observed when crud.read called on top level object bgp_oper_obj .

System Information

YDK-0.8.5

ygorelik avatar Nov 03 '20 18:11 ygorelik