In an effort to evaluate suspensions earlier so that we can minimize
excess buffering, I've discovered that this is causing problems related
to suspensions that create other suspensions. I think normally this
isn't an issue because we evaluate suspensions at the end, so the nested
suspensions don't actually need to suspend. But now that I'm trying to
evaluate suspensions earlier, the nested suspensions actually do need to
suspend.

Only about a dozen tests fail right now with my changes to evaluate
suspensions earlier, but the simplest one is
test_sequenceWithComplexType. This test is a sequence of prefix
separated elements:

https://github.com/apache/incubator-daffodil/blob/master/daffodil-test/src/test/resources/org/apache/daffodil/section14/sequence_groups/sequenceWithComplexType.dfdl.xsd

I believe what is happening during unparse is we create a suspension to
determine if the unparsed element is zero length or not, which
determines if we should unparse a separator. At some point, the
suspension determines the unparsed element is not zero length, and the
suspension runs the separator unparser and then finishes.

The problem is that running this separator unparser triggers an
alignment unparser, which at the time of evaluation needs to suspend.
The DOS that this alignment parser suspends on has already been split
(other things have suspended before we reevaluate the separator
suspension), which currently fails due to an assertion. We currently
only ever allow suspending from he last DOS, not a previous DOS.

My first instinct was to change this assumption to allow suspensions on
an older DOS, and to just sort of stick the new suspension DOS in the
middle of DOS's. I have this working, but this still results in blocks
on the alignment suspensions. I haven't quite figured out what's causing
these blocks. I suspect that there's just something extra that I need to
do to allow arbitrarily inserting DOSs.

So there's definitely more debugging to do, but wanted to bring this up
before I get too far down the rabbit hole.

Any thoughts if this is the right approach, or perhaps there's some
other fundamental change to how suspensions need to be handled to allow
this to work?

Reply via email to