Project

Profile

Help

Bug #3797

closed

NPE in stylesheet compilation (no retained static context)

Added by Toshihiko Makita almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2018-05-29
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Platforms:

Description

NPE occurred during stylesheet compilation.

Command-line result

How to reproduce the problem:

  1. Unzip attached dita-ot-3.0.3-bil.zip to any folder.

  2. Modify dita-ot-3.0.3-bil/test-npe.bat according to your operating environment.

  3. Run dita-ot-3.0.3-bil/test-npe.bat


Files

2018-05-29.png (50.1 KB) 2018-05-29.png Command-line result Toshihiko Makita, 2018-05-29 02:32
dita-ot-3.0.3-bil.zip (41.3 MB) dita-ot-3.0.3-bil.zip Stylesheet & DITA-OT archive Toshihiko Makita, 2018-05-29 02:46
Actions #1

Updated by Toshihiko Makita almost 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>
Actions #2

Updated by Michael Kay almost 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
Actions #3

Updated by Michael Kay almost 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.

Actions #4

Updated by Michael Kay almost 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.

Actions #5

Updated by Michael Kay almost 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
Actions #6

Updated by Debbie Lockett almost 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.

Actions #7

Updated by Michael Kay almost 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

Also available in: Atom PDF