parsing BUGFIX invalid backward parent pointer#2432
Conversation
3fc94e9 to
4c9e18f
Compare
michalvasko
left a comment
There was a problem hiding this comment.
The solution seems a bit like a workaround and I think another solution would be better. The parent can be corrected right when it becomes invalid, which is when the grouping content is being copied into the uses. So the code would go through all the direct substatements of the grouping and correct parents in all the extensions.
I am also wondering about an extension directly under the grouping. If it is copied into the uses, not just the parent should be changed but the parent type as well. Another test for this should be added in any case. Let me know if I should implement all this instead.
|
I think your proposal is not correct. The problem that I was facing was already in parsed tree structure, not in compiled. The pointer of parent is actually corrected exactly after it become invalidated. It become invalidated due to usage of LY_ARRAY on refines and typedefs, which requires usage of LY_ARRAY_NEW, which moves it content in memory without ability to update internally the content of data that are being moved....So if you add first refine with extension. Everything works correct. But immediately if you put another one, that one will invalidate the parent pointer of extension from the previous one. AFAIK there is no other way to tell when the pointer of The only better solution I can think of would be to change refines and typedefs from LY_ARRAY to linked list, which will not be facing this kind of issue, but that would also mean change of public API, so I didn't went this way. Feel free to do whatever you think is the best for libyang. As long as my proposed tests will not show any valgrind issues (like invalid read) I am ok with it. |
|
Okay, then I misunderstood the issue and it is simpler than I thought. Please document the actual problem ( |
This patch fixes the issue if extensions are used within subsequent refine or typedef statements
4c9e18f to
10f211e
Compare
|
Not sure if I understood you correctly, I assumed you mean document it directly in the code. So I have extended little bit the comments. Hope it is enough. |
|
Yes, I meant in the code, is fine now. |
This patch fixes the issue if extensions are used within subsequent refine or typedef statements