Bug #3797
closedNPE in stylesheet compilation (no retained static context)
100%
Description
NPE occurred during stylesheet compilation.
How to reproduce the problem:
-
Unzip attached dita-ot-3.0.3-bil.zip to any folder.
-
Modify dita-ot-3.0.3-bil/test-npe.bat according to your operating environment.
-
Run dita-ot-3.0.3-bil/test-npe.bat
Files
Updated by Toshihiko Makita over 6 years ago
NPE occurs in the following code (dita2wml_global_drawing.xsl):
<xsl:for-each select="$map/descendant::*[contains(@class,' bookmap/toc ')]">
<xsl:variable name="toc" as="element()" select="."/>
<xsl:variable name="tocId" as="xs:string" select="ahf:generateId($toc)"/>
<xsl:sequence select="$tocId"/>
<xsl:for-each select="$map/descendant::*[ahf:seqContains(string(@class),(' bookmap/chapter ',' bookmap/appendix ',' bookmap/indexlist'))]">
<xsl:variable name="topicRef" as="element()" select="."/>
<xsl:variable name="chapterNo" as="xs:string" select="ahf:getChapterNo($topicRef)"/>
<xsl:sequence select="concat($tocId,'-',$chapterNo)"/>
</xsl:for-each>
</xsl:for-each></code>
If I modified such as following, the NPE has been vanished.
<xsl:variable name="toc" as="element()?" select="$map/descendant::*[contains(@class,' bookmap/toc ')][1]"/>
<xsl:if test="exists($toc)">
<xsl:variable name="tocId" as="xs:string" select="ahf:generateId($toc)"/>
<xsl:sequence select="$tocId"/>
<xsl:for-each select="$map/descendant::*[ahf:seqContains(string(@class),(' bookmap/chapter ',' bookmap/appendix ',' bookmap/indexlist'))]">
<xsl:variable name="topicRef" as="element()" select="."/>
<xsl:variable name="chapterNo" as="xs:string" select="ahf:getChapterNo($topicRef)"/>
<xsl:sequence select="concat($tocId,'-',$chapterNo)"/>
</xsl:for-each>
</xsl:if></code>
Updated by Michael Kay over 6 years ago
- Subject changed from NPE in stylesheet compailation to NPE in stylesheet compilation
- Status changed from New to In Progress
- Assignee set to Michael Kay
Updated by Michael Kay over 6 years ago
I have reproduced the problem, but so far I'm no nearer to working out why the relevant expression has no retainedStaticContext. It had one when it was first created, but it's been through a number of complex rewrites (function inlining, loop lifting etc) before the failure occurs.
Updated by Michael Kay over 6 years ago
The two methods Expression.setRetainedStaticContext() and Expression.setRetainedStaticContextThoroughly() don't check that the supplied static context is non-null. Since an expression can have a null retained static context transiently while it is being created, this creates the risk that the null value for retainedStaticContext will be propagated and overwrite the retained static context of expressions that already have an RSC.
Changing this methods to do nothing if the supplied RSC is null solves the problem for this test case. It's not a 100% solution that ensures the retained static context will never be null, but it's a useful defensive measure.
Updated by Michael Kay over 6 years ago
- Category set to Internals
- Status changed from In Progress to Resolved
- Applies to branch trunk added
- Fix Committed on Branch 9.8, trunk added
Updated by Debbie Lockett over 6 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.8.0.14 added
Bug fix applied in the Saxon 9.8.0.14 maintenance release.
Updated by Michael Kay over 6 years ago
- Subject changed from NPE in stylesheet compilation to NPE in stylesheet compilation (no retained static context)
- Description updated (diff)
Please register to edit this issue