[YANGTOOLS-411] StackOverflowError for leafref Created: 14/Feb/15  Updated: 10/Apr/22  Resolved: 18/Jun/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Minna Hu Assignee: Martin Ciglan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: File ietf-ospf@2014-09-17.yang    
External issue ID: 2721

 Description   

I want to generate JAVA classes from ietf-ospf, I hit StackOverflowError at the following definition, and the generation failed.

list neighbor {
description
"List of neighbors.";
leaf neighbor-id {
type leafref

{ path "../../neighbor/neighbor-id"; }

description "Neighbor.";
}
}

If I replace path "../../neighbor/neighbor-id" with concrete path "/rt:routing-state/rt:routing-instance/"
+ "rt:routing-protocols/rt:routing-protocol/"
+ "ospf:ospf/ospf:instance/ospf:neighbor/ospf:neighbor-id";", the error is solved.

How can we solve the StackOverflowError without modifying ietf-ospf file? Could we fix it in yang-tools? Thank you!

ietf-ospf.yang file is attached. Error message is:
java.lang.StackOverflowError
at org.opendaylight.yangtools.yang.common.QName.create(QName.java:254)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.stringPathPartToQName(SchemaContextUtil.java:513)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.access$000(SchemaContextUtil.java:50)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil$1.apply(SchemaContextUtil.java:600)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil$1.apply(SchemaContextUtil.java:597)
at com.google.common.collect.Iterators$8.transform(Iterators.java:860)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at com.google.common.collect.Iterators$5.next(Iterators.java:607)
at com.google.common.collect.Iterables$10$1.next(Iterables.java:926)
at com.google.common.collect.Iterators.advance(Iterators.java:979)
at com.google.common.collect.Iterables$10.iterator(Iterables.java:904)
at com.google.common.collect.Iterables$10.iterator(Iterables.java:902)



 Comments   
Comment by Minna Hu [ 14/Feb/15 ]

Attachment ietf-ospf@2014-09-17.yang has been added with description: ietf-ospf

Comment by Tony Tkacik [ 16/Feb/15 ]

interface-operation {
list neighbor {
description
"List of neighbors.";
leaf neighbor-id {
type leafref

{ path "../../neighbor/neighbor-id"; }

}
}

This seems bit weird - this set of leafrefs references themselves (recursive definition), so there is not initial set of valid values, need to co

Definitelly StackOverflowError is bug, but looking at original model - that one is not correct also. I believe that path should be ../../../
path ../../ points to place where interface-operation is used, and then applying
neighbor/neighbor-id will point back to that particular leafref.

Comment by Minna Hu [ 17/Feb/15 ]

Thanks, Tony! The model is from IETF, I did not know why they defined the model in this way.

You had good founding, the model will definitely causes StackOverflowError. Besides modifying the model, is there any way to handle the situation in yang-tools? Thanks!

Comment by Martin Ciglan [ 23/Feb/15 ]

I propose checking schema node and leafref itself (going through schema path) to see if they match (leafref referencing itself) and in that case, throw exception.

work in progress...

Comment by Minna Hu [ 24/Feb/15 ]

Martin, thank you for your reply! Just to clarify, are you checking schema node and leafref? Or are you proposing for me to do that? Thanks!

Comment by Martin Ciglan [ 24/Feb/15 ]

I am actually working on it, will come back to you with result

Comment by Robert Varga [ 11/Jun/15 ]

Needs to be fixed before Lithium goes out.

Comment by Martin Ciglan [ 16/Jun/15 ]

fix pushed:

https://git.opendaylight.org/gerrit/#/c/22698/

Generated at Wed Feb 07 20:53:10 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.