Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2078

Unexpected exception with dfdl:contentLength

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0
    • 2.4.0
    • Back End
    • None

    Description

      DFDL schema which uses the dfdl:contentLength on a parent node fails to compile, even when the length is explicit.

      I am unsure if the attached schema should compile. In general it is not possible to use dfdl:contentLength on a parent node, as said node has not yet finished parsing. However, when the lengthKind is explicitly the value is knowable. Regardless, if this is not allowed, a better error message is needed.

       

      To reproduce, run ``` daffodil save-parser -s test.dfdl.xsd test.dfdl.xsd.bin ``` on the attached schema. Relevent portion reproduced below:

      ```

      <xs:element name="x" dfdl:lengthKind="explicit" dfdl:length="{ 1 }">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="y" type="xs:int" dfdl:occursCountKind="expression" dfdl:occursCount='{ if(dfdl:contentLength(.., "bits") eq 0) then 1 else 2 }' dfdl:inputValueCalc="{ 1 }" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>

      ```

       

      Full error is:

       

      ```

      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      !! An unexpected exception occurred. This is a bug! !!
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      Please report this bug and help us fix it:

      https://daffodil.apache.org/community/#issue-tracker

      Please include the following exception, the command you
      ran, and any input, schema, or tdml files used that led
      to this bug.

      java.lang.NullPointerException
      at org.apache.daffodil.infoset.InfosetLengthUnknownException.<init>(InfosetImpl.scala:192)
      at org.apache.daffodil.infoset.InfosetContentLengthUnknownException.<init>(InfosetImpl.scala:201)
      at org.apache.daffodil.infoset.ContentLengthState.throwUnknown(InfosetImpl.scala:558)
      at org.apache.daffodil.infoset.LengthState.lengthInBits(InfosetImpl.scala:488)
      at org.apache.daffodil.dpath.DFDLLengthFunctionBase.$anonfun$getLength$1(DFDLFunctions2.scala:35)
      at org.apache.daffodil.dpath.DFDLLengthFunctionBase.$anonfun$getLength$1$adapted(DFDLFunctions2.scala:34)
      at org.apache.daffodil.dpath.DState$.withRetryIfBlocking(DState.scala:364)
      at org.apache.daffodil.dpath.DFDLLengthFunctionBase.getLength(DFDLFunctions2.scala:34)
      at org.apache.daffodil.dpath.DFDLLengthFunctionBase.computeValue(DFDLFunctions2.scala:70)
      at org.apache.daffodil.dpath.FNTwoArgsNodeAndValue.run(FNBases.scala:163)
      at org.apache.daffodil.dpath.CompiledDPath.run(DPathRuntime.scala:127)
      at org.apache.daffodil.dpath.CompareOperator.run(DPathRuntime.scala:230)
      at org.apache.daffodil.dpath.CompiledDPath.run(DPathRuntime.scala:127)
      at org.apache.daffodil.dpath.IF.run(DPathRuntime.scala:193)
      at org.apache.daffodil.dpath.CompiledDPath.run(DPathRuntime.scala:127)
      at org.apache.daffodil.dpath.CompiledDPath.runExpressionForConstant(DPathRuntime.scala:81)
      at org.apache.daffodil.dpath.DFDLPathExpressionParser.compile(DFDLExpressionParser.scala:55)
      at org.apache.daffodil.dsom.ExpressionCompiler.compileExpression1(CompiledExpression.scala:208)
      at org.apache.daffodil.dsom.ExpressionCompiler.compileExpression(CompiledExpression.scala:50)
      at org.apache.daffodil.dsom.ExpressionCompiler.compileProperty(CompiledExpression.scala:73)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.$anonfun$occursCountExpr$1(RuntimePropertyMixins.scala:453)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$occursCountExpr(RuntimePropertyMixins.scala:450)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$occursCountExpr$(RuntimePropertyMixins.scala:450)
      at org.apache.daffodil.dsom.LocalElementDecl.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$occursCountExpr$lzycompute(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.LocalElementDecl.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$occursCountExpr(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.occursCountEv(RuntimePropertyMixins.scala:457)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.occursCountEv$(RuntimePropertyMixins.scala:456)
      at org.apache.daffodil.dsom.LocalElementDecl.occursCountEv$lzycompute(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.LocalElementDecl.occursCountEv(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.$anonfun$localElementPropertyReferencedElements$2(RuntimePropertyMixins.scala:484)
      at org.apache.daffodil.dsom.PropertyReferencedElementInfosMixin.ev$lzycompute$1(RealTermMixin.scala:32)
      at org.apache.daffodil.dsom.PropertyReferencedElementInfosMixin.ev$1(RealTermMixin.scala:32)
      at org.apache.daffodil.dsom.PropertyReferencedElementInfosMixin.propExprElts(RealTermMixin.scala:33)
      at org.apache.daffodil.dsom.PropertyReferencedElementInfosMixin.propExprElts$(RealTermMixin.scala:29)
      at org.apache.daffodil.dsom.LocalElementDecl.propExprElts(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.localElementPropertyReferencedElements(RuntimePropertyMixins.scala:484)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$myPropertyContentReferencedElementInfos(RuntimePropertyMixins.scala:514)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$myPropertyContentReferencedElementInfos$(RuntimePropertyMixins.scala:513)
      at org.apache.daffodil.dsom.LocalElementDecl.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$myPropertyContentReferencedElementInfos$lzycompute(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.LocalElementDecl.org$apache$daffodil$dsom$ElementRuntimeValuedPropertiesMixin$$myPropertyContentReferencedElementInfos(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.propertyContentReferencedElementInfos(RuntimePropertyMixins.scala:517)
      at org.apache.daffodil.dsom.ElementRuntimeValuedPropertiesMixin.propertyContentReferencedElementInfos$(RuntimePropertyMixins.scala:516)
      at org.apache.daffodil.dsom.LocalElementDecl.propertyContentReferencedElementInfos(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.Term.contentLengthParserReferencedElementInfos(Term.scala:751)
      at org.apache.daffodil.dsom.Term.contentLengthParserReferencedElementInfos$(Term.scala:750)
      at org.apache.daffodil.dsom.LocalElementDecl.contentLengthParserReferencedElementInfos$lzycompute(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.LocalElementDecl.contentLengthParserReferencedElementInfos(LocalElementDecl.scala:22)
      at org.apache.daffodil.dsom.Term.$anonfun$contentLengthParserReferencedElementInfos$1(Term.scala:755)
      at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:122)
      at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:118)
      at scala.collection.immutable.List.foldLeft(List.scala:86)
      at org.apache.daffodil.dsom.Term.contentLengthParserReferencedElementInfos(Term.scala:755)
      at org.apache.daffodil.dsom.Term.contentLengthParserReferencedElementInfos$(Term.scala:750)
      at org.apache.daffodil.dsom.ModelGroup.contentLengthParserReferencedElementInfos$lzycompute(ModelGroup.scala:129)
      at org.apache.daffodil.dsom.ModelGroup.contentLengthParserReferencedElementInfos(ModelGroup.scala:129)
      at org.apache.daffodil.dsom.Term.$anonfun$contentLengthParserReferencedElementInfos$1(Term.scala:755)
      at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:122)
      at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:118)
      at scala.collection.immutable.List.foldLeft(List.scala:86)
      at org.apache.daffodil.dsom.Term.contentLengthParserReferencedElementInfos(Term.scala:755)
      at org.apache.daffodil.dsom.Term.contentLengthParserReferencedElementInfos$(Term.scala:750)
      at org.apache.daffodil.dsom.AbstractElementRef.contentLengthParserReferencedElementInfos$lzycompute(ElementRef.scala:31)
      at org.apache.daffodil.dsom.AbstractElementRef.contentLengthParserReferencedElementInfos(ElementRef.scala:31)
      at org.apache.daffodil.dsom.ElementBase.isReferencedByContentLengthParserExpressions(ElementBase.scala:177)
      at org.apache.daffodil.dsom.ElementBase.isReferencedByContentLengthParserExpressions$(ElementBase.scala:173)
      at org.apache.daffodil.dsom.AbstractElementRef.isReferencedByContentLengthParserExpressions$lzycompute(ElementRef.scala:31)
      at org.apache.daffodil.dsom.AbstractElementRef.isReferencedByContentLengthParserExpressions(ElementRef.scala:31)
      at org.apache.daffodil.grammar.primitives.CaptureContentLengthStart.parser(ElementCombinator.scala:229)
      at org.apache.daffodil.grammar.SeqComp.$anonfun$parserChildren$2(Grammar.scala:95)
      at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
      at scala.collection.immutable.List.foreach(List.scala:389)
      at scala.collection.TraversableLike.map(TraversableLike.scala:234)
      at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
      at scala.collection.immutable.List.map(List.scala:295)
      at org.apache.daffodil.grammar.SeqComp.parserChildren$lzycompute(Grammar.scala:95)
      at org.apache.daffodil.grammar.SeqComp.parserChildren(Grammar.scala:95)
      at org.apache.daffodil.grammar.SeqComp.parser$lzycompute(Grammar.scala:98)
      at org.apache.daffodil.grammar.SeqComp.parser(Grammar.scala:97)
      at org.apache.daffodil.grammar.Prod.parser$lzycompute(Production.scala:80)
      at org.apache.daffodil.grammar.Prod.parser(Production.scala:76)
      at org.apache.daffodil.grammar.Gram.maybeParser(GrammarTerm.scala:127)
      at org.apache.daffodil.grammar.primitives.ElementCombinatorBase.eParser$lzycompute(ElementCombinator.scala:443)
      at org.apache.daffodil.grammar.primitives.ElementCombinatorBase.eParser(ElementCombinator.scala:443)
      at org.apache.daffodil.grammar.primitives.ElementParseAndUnspecifiedLength.parser$lzycompute(ElementCombinator.scala:350)
      at org.apache.daffodil.grammar.primitives.ElementParseAndUnspecifiedLength.parser(ElementCombinator.scala:339)
      at org.apache.daffodil.grammar.primitives.ElementCombinator.parser$lzycompute(ElementCombinator.scala:95)
      at org.apache.daffodil.grammar.primitives.ElementCombinator.parser(ElementCombinator.scala:89)
      at org.apache.daffodil.grammar.Prod.parser$lzycompute(Production.scala:80)
      at org.apache.daffodil.grammar.Prod.parser(Production.scala:76)
      at org.apache.daffodil.grammar.Prod.parser$lzycompute(Production.scala:80)
      at org.apache.daffodil.grammar.Prod.parser(Production.scala:76)
      at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$parser$1(Compiler.scala:79)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
      at org.apache.daffodil.compiler.ProcessorFactory.parser$lzycompute(Compiler.scala:78)
      at org.apache.daffodil.compiler.ProcessorFactory.parser(Compiler.scala:78)
      at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$new$3(Compiler.scala:103)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.liftedTree1$1(OOLAG.scala:585)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:583)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:581)
      at org.apache.daffodil.oolag.OOLAG$OOLAGValue.valueAsAny(OOLAG.scala:579)
      at org.apache.daffodil.oolag.OOLAG$OOLAGHost.$anonfun$checkErrors$2(OOLAG.scala:287)
      at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
      at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
      at org.apache.daffodil.oolag.OOLAG$OOLAGHost.checkErrors(OOLAG.scala:287)
      at org.apache.daffodil.oolag.OOLAG$OOLAGHost.checkErrors$(OOLAG.scala:278)
      at org.apache.daffodil.dsom.SchemaComponentImpl.checkErrors(SchemaComponent.scala:37)
      at org.apache.daffodil.oolag.OOLAG$OOLAGHost.isError(OOLAG.scala:346)
      at org.apache.daffodil.oolag.OOLAG$OOLAGHost.isError$(OOLAG.scala:345)
      at org.apache.daffodil.compiler.ProcessorFactory.super$isError(Compiler.scala:118)
      at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:118)
      at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
      at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
      at org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:109)
      at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
      at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
      at org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
      at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:109)
      at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:336)
      at org.apache.daffodil.Main$.$anonfun$createProcessorFromSchema$1(Main.scala:715)
      at org.apache.daffodil.util.Timer$.getTimeResult(Timer.scala:76)
      at org.apache.daffodil.util.Timer$.getResult(Timer.scala:35)
      at org.apache.daffodil.Main$.createProcessorFromSchema(Main.scala:714)
      at org.apache.daffodil.Main$.run(Main.scala:1166)
      at org.apache.daffodil.Main$.main(Main.scala:1341)
      at org.apache.daffodil.Main.main(Main.scala)

      ```

      Attachments

        1. test.dfdl.xsd
          2 kB
          Brandon Sloane

        Activity

          People

            slawrence Steve Lawrence
            brandon.sloane Brandon Sloane
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: