olabusayoT commented on code in PR #1717:
URL: https://github.com/apache/daffodil/pull/1717#discussion_r3866251882


##########
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/Suspension.scala:
##########
@@ -228,9 +253,53 @@ trait Suspension extends Serializable {
 
   final def isMakingProgress = isMakingProgress_
 
+  // Which SuspensionWaiter (if any) this suspension is registered with.
+  // block() unconditionally deregisters this before any retry, so
+  // registerWaiter never finds one already set.
+  private var maybeRegisteredWaiter: Maybe[SuspensionWaiter] = Nope

Review Comment:
    I don't think this can be removed. For example, if a suspension blocks on 
element A's length, registers with lengthStateA.suspensionWaiter, then on a 
later retry its dependency shifts to element B (registers with 
lengthStateB.suspensionWaiter instead) i.e without A ever resolving. If 
Suspension doesn't know which waiter it was previously on, block() has no way 
to call lengthStateA.suspensionWaiter.removeSuspension(this), so the suspension 
stays reachable from A forever. It's also not just a memory leak since if A's 
notifySuspensions() eventually fires (independently, for unrelated reasons), it 
would call moveFromParkedToYoung() on a suspension that's actually now waiting 
on B, clearing its current registration with B and moving it to young based on 
a stale, irrelevant event, while B's suspensionWaiter set still (incorrectly) 
thinks it holds that suspension. So the waiter-side alone can't manage this; 
the suspension needs its own back-reference specifically to handle the "dependen
 cy moved to a different waiter" case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to