You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/02/15 17:01:01 UTC

[GitHub] [daffodil] mbeckerle commented on a change in pull request #754: WIP: Call setFinished on the correct data output stream

mbeckerle commented on a change in pull request #754:
URL: https://github.com/apache/daffodil/pull/754#discussion_r807076280



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/unparsers/UState.scala
##########
@@ -344,7 +342,24 @@ abstract class UState(
       // Finished means you won't add data to the end of it any more.
       // It does NOT prevent information like the absoluteBitPos to
       // propagate.
-      dos.setFinished(this)
+      //
+      // When setFinished is called the DOS is going to store the state that we
+      // pass into it in finishedFormatInfo. Eventually this DOS will become a
+      // direct DOS that may be delivered to a following buffered DOS. When that
+      // happens this saved finishedFormatInfo will be used. However, this
+      // requires that the UState does not change while we are waiting for this
+      // DOS to become direct. If the state does change, it will become
+      // incorrect and can lead to undefined behavior. To prevent this, we must
+      // clone the UState so it can no longer change, and pass that clone into
+      // setFinished.
+      val finfo = this match {
+        case m: UStateMain => m.cloneForSuspension(dos)
+        case _ => Assert.invariantFailed("State must be a UStateMain when splitting for bit order change")
+      }

Review comment:
       I wish we didn't have to put these COVERAGE-OFF and COVERAGE-ON brackets around Assert.invariantFailed, but we seem to have to. I'd like a way to inform it that Assert.impossible and Assert.invariantFailed are always coverage off. 




-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org