cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

I am facing a memory overflow and array index out of bound issue in YDK. I have fixed these issues. How to proceed further?

ravi_sabapathy
Beginner
Beginner

Root cause Analysis:

I was facing issues when I tried to compile YDK with augmented ietf_interface values. The issue is with the YDK parsing file. There were 2 issues,

         1. The YDK parser file take the base ietf_interface.py file and our augmented ietf file. It then creates a new ietf_interfaces.py file in "_aug_patch" folder with both base ietf and augmented ietf content. While parsing the comment section, the code hits a logic of end of comment (""") in the generated augmented ietf_interfaces.py file.  Ideally the logic should have ended comment parsing.  But instead the data index is decremented.

                              file:- __init__.py in ietf folder


                              if '"""' in patch_lines[idx]):

                                         idx -=2

                  This was causing the code to access the same index again and again which resulted in the looping. This was causing memory issue.

       2. In addition to the looping issue, there was array index out of bound issue.  Because of this issue the ietf_interfaces.py was not properly generated in the ietf/_aug_patch folder. IT was giving IndexError.


      I have fixed both the issues. It is purely YDK issue. The issue should be fixed in the file ydk-gen/ydkgen/printer/python/init_file_printer.py. I have attached the modified _patch() function.

1 ACCEPTED SOLUTION

Accepted Solutions

xiaoqinz
Enthusiast
Enthusiast

Just to clarify and for future reference,

The issue is about old Python package generated by YDK-GEN before 0.5.4 interfere with new Python package generated after 0.5.4. If you have old Python package generated and installed by YDK-GEN before 0.5.4, and facing similar issue above(error in "_aug_patch"), please uninstall them and regenerate the reinstall using YDK-GEN>=0.5.4:

$ pip list | grep ydk-models

ydk-models-cisco-ios-xr 6.2.1

ydk-models-openconfig   0.1.2

ydk-models-ietf         0.1.1

# ^~~~ if you installed ydk-models-ietf through YDK-GEN<0.5.4,

# and generated then installed new custom package with YANG model augment models

# in this package(for example ietf-interfaces in this case), it might cause

# you trouble, please refresh your environment by removing all of them:

$ pip uninstall ydk-models-cisco-ios-xr ydk-models-ietf ydk-models-openconfig -y

# and regenerate/reinstall them:

ydk-gen $ ./generate.py --bundle profiles/bundles/ietf_0_1_1.json

ydk-gen $ ./generate.py --bundle custom.json

ydk-gen $ pip install gen-api/python/ietf-bundle/dist/ydk*.gz

ydk-gen $ pip install gen-api/python/custom-bundle/dist/ydk*.gz

Apologize for inconvenience.

View solution in original post

3 REPLIES 3

einarnn
Cisco Employee
Cisco Employee

Ravi,

It would be great if you could do a couple of things:

  • Raise an issue on the github issue tracker in the repo CiscoDevNet/ydk-gen
  • Fork that same repository and apply your patch, and submit a pull request referencing the issue you raised.

Cheers,

Einar

xiaoqinz
Enthusiast
Enthusiast

Sorry, just saw this discussion. I checked the init_file_priner.py in current ydk-gen repository this time and found the code causing this issue is being removed after this commit. I think it should be fine if YDK is upgraded to 0.5.4(pip install ydk --upgrade). Let me know if it helps.

xiaoqinz
Enthusiast
Enthusiast

Just to clarify and for future reference,

The issue is about old Python package generated by YDK-GEN before 0.5.4 interfere with new Python package generated after 0.5.4. If you have old Python package generated and installed by YDK-GEN before 0.5.4, and facing similar issue above(error in "_aug_patch"), please uninstall them and regenerate the reinstall using YDK-GEN>=0.5.4:

$ pip list | grep ydk-models

ydk-models-cisco-ios-xr 6.2.1

ydk-models-openconfig   0.1.2

ydk-models-ietf         0.1.1

# ^~~~ if you installed ydk-models-ietf through YDK-GEN<0.5.4,

# and generated then installed new custom package with YANG model augment models

# in this package(for example ietf-interfaces in this case), it might cause

# you trouble, please refresh your environment by removing all of them:

$ pip uninstall ydk-models-cisco-ios-xr ydk-models-ietf ydk-models-openconfig -y

# and regenerate/reinstall them:

ydk-gen $ ./generate.py --bundle profiles/bundles/ietf_0_1_1.json

ydk-gen $ ./generate.py --bundle custom.json

ydk-gen $ pip install gen-api/python/ietf-bundle/dist/ydk*.gz

ydk-gen $ pip install gen-api/python/custom-bundle/dist/ydk*.gz

Apologize for inconvenience.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: