Skip to content

Re-used references shared between yielded final expressions from AbstractDataAccessRule #3462

Open
@alecgrieser

Description

@alecgrieser

While looking at fixing potential leaks in the Traversal as part of #3435, one thing that I found was that for certain rules, we may be re-using references amongst multiple final expressions. One of the invariants that we want to maintain is that final expressions own the references that they are over--that is, there shouldn't be more than one expression pointing to the same reference. In certain rules though (like the SelectDataAccessRule), it appears that we are creating a set of references, memoizing them, and then using them as children to a new set of expressions, some of which are final.

The consequence of this is that multiple expressions (in the same new reference) may point to the same reference. I noticed this when I added the following check: when yielding an expression, check to see if expression was not actually added because it is a duplicate of an existing member of the reference. If it was not added, then remove any of its children from the memo structure. The issue with that check is that I started getting verification errors from verifyChildrenMemoized. When I tracked it down, it was clear that multiple parent expressions were being added that were all over the same children. In cases where one new expression was a duplicate but the other one was not, we would end up memoizing the child for the first one, then removing it after the first expression wasn't actually yielded, and then finding that we need it when verifying the children of the second expression were in the memo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions