Skip to content

Commit 4eaa7b2

Browse files
committed
internal/core/adt: add some defensive code
This change is needed for an upcoming change, where it would otherwise cause a crash. It addresses a few issues: In allChildConjunctsKnown: it was sometimes called with a status that is finalized. This was possible in some rare cases. It should be safe to simply return true in these cases, so that is what we do now. Separately, we changed one of the call sites in unify to no call this function if such a condition is met. Note that Rooted additionally tests whether the nonRooted flag is set. We separate out these changes so that bisection will isolate any issues caused by this. Issue #2854 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I87df035ccdde61309884391131fa2a6de7d4887e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202209 Reviewed-by: Matthew Sackman <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 29b466e commit 4eaa7b2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/core/adt/states.go

+9
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ func (v *Vertex) allChildConjunctsKnown() bool {
294294
return true
295295
}
296296

297+
if v.status == finalized {
298+
// This can happen, for instance, if this is called on a parent of a
299+
// rooted node that is marked as a parent for a dynamic node.
300+
// In practice this should be handled by the caller, but we add this
301+
// as an extra safeguard.
302+
// TODO: remove this check at some point.
303+
return true
304+
}
305+
297306
return v.state.meets(fieldConjunctsKnown | allAncestorsProcessed)
298307
}
299308

internal/core/adt/unify.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool {
152152
// Note that if mode is final, we will guarantee that the conditions for
153153
// this if clause are met down the line. So we assume this is already the
154154
// case and set the signal accordingly if so.
155-
if v.Label.IsLet() || v.IsDynamic || v.Parent.allChildConjunctsKnown() || mode == finalize {
155+
if !v.Rooted() || v.Parent.allChildConjunctsKnown() || mode == finalize {
156156
n.signal(allAncestorsProcessed)
157157
}
158158

0 commit comments

Comments
 (0)