this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: avoid crash

Sometimes, evaluation of a Vertex may, recursively,
trigger the evaluation of itself. This may cause
the checks or Arc slices to be reset while they are
in the process of being filtered. As filtering is no
longer needed if a node is already finalized, we can
safely drop out of the computation if we detect this.

Note that there are no test cases. Issues around this
were detected by upcoming changes that fix hangs
in cyclic function and validator calls. We separate out
these changes, though, so that we can see they are
a noop and to facilitate bisection if these turn out to
be problamatic after all.

Issue #3649

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: If298ba3d9bd4addde0ac1d55be968211660bc113
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1208699
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+13 -1
+6 -1
internal/core/adt/conjunct.go
··· 784 784 785 785 for i, y := range n.checks { 786 786 if b, ok := SimplifyValidator(ctx, cx, y); ok { 787 - n.checks[i] = b 787 + // It is possible that simplification process triggered further 788 + // evaluation, finalizing this node and clearing the checks 789 + // slice. In that case it is safe to ignore the result. 790 + if len(n.checks) > 0 { 791 + n.checks[i] = b 792 + } 788 793 return 789 794 } 790 795 }
+7
internal/core/adt/eval.go
··· 860 860 } 861 861 } 862 862 863 + // If a structural cycle is detected, Arcs is cleared to avoid 864 + // going into an infinite loop. If this is the case, we can bail 865 + // from this loop. 866 + if len(n.node.Arcs) == 0 { 867 + goto postChecks 868 + } 863 869 n.node.Arcs[k] = a 864 870 k++ 865 871 ··· 889 895 } 890 896 n.node.Arcs = n.node.Arcs[:k] 891 897 898 + postChecks: 892 899 for _, c := range n.postChecks { 893 900 f := ctx.PushState(c.env, c.expr.Source()) 894 901