Subject: Re: bug#60054: 29.0.60; Infinite loop when there are cyclic path in the parse tree

From: Yuan Fu <[email-masked]>
Date: Sat, 17 Dec 2022 15:28:01 -0800

Yuan Fu <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>>> From: Yuan Fu <[email-masked]>
>>> Date: Wed, 14 Dec 2022 12:27:58 -0800
>>> Cc: [email-masked]
>>> 
>>> >> https://github.com/tree-sitter/tree-sitter-c/issues/119
>>> >> 
>>> >> So far, I’ve only observed this in that specific edge case.
>>> > 
>>> > We should have protection against that, which should be easy, right?
>>> 
>>> Just to make sure, we want to use something like slow-fast pointers,
>>> where we have two pointers, and one goes twice as fast, right?
>>> That’s the one I was taught in school :-)
>>
>> No, I mean protect us from inflooping by checking that the parent of a
>> node is not the node itself.
>
> In this particular case, it is the siblings’ parent that equals to the
> node. Ie, node->sibling->parent = node.  If your intention is to protect
> us from this particular case, switching to use cursors will avoid this
> bug.

Ok, I made the change to use cursor API with tests. Hopefully this is
the last time we need to change treesit.c before release. The
node->sibling->parent = node cyclic path should be fixed by this change,
do you still want checks for it?

Yuan