Project

Profile

Help

Bug #4117

closed

java.lang.AssertionError : Target of component reference variable keywords is undefined (caused by inlining function calls across a package boundary)

Added by Jiri Dolejsi almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2019-01-29
Due date:
% Done:

100%

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

Description

SUMMARY

This problem was caused by attempting to inline a function call to a function in a different package, where the called function accessed global variables private to that package.

ORIGINAL REPORT

We are using Saxon 9.9 EE/N. Following code throws exception java.lang.AssertionError

 class Program
    {
        static Processor processor = new Processor(true);

        static string p =
            @"<xsl:package name='http://www.ctk.cz/keywords/' " +
            @"  xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' version='3.0' " +
            @"  xmlns:kw='http://www.ctk.cz/keywords/'>" +
            @"  <xsl:variable name='keywords' as='document-node()' static='yes'  select='parse-xml(""&lt;Keywords&gt;&lt;/Keywords&gt;"")'/>" +
            @"  <xsl:function name='kw:get-keyword-value' as='xs:string' visibility='final'>" +
            @"     <xsl:param name = 'qcode' as= 'xs:string'/>" +
            @"     <xsl:sequence select='$keywords/Keywords//Keyword[@qcode eq $qcode]/Value'/>" +
            @"  </xsl:function>" +
            @"</xsl:package>";
   
	
        static string s =
            @"<xsl:transform version='3.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:kw='http://www.ctk.cz/keywords/'> " +
            @"  <xsl:use-package name='http://www.ctk.cz/keywords/'/>" +
            @"  <xsl:template name='xsl:initial-template'> " +
            @"      <out x='{kw:get-keyword-value(""abc"")}'/>" +
            @"  </xsl:template>" +
            @"</xsl:transform>";

        static void Main(string[] args)
        {

            processor.SetProperty("http://saxon.sf.net/feature/optimizationLevel", "-j");
            XsltCompiler xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.XsltLanguageVersion = "3.0";
            var ms = new MemoryStream(Encoding.UTF8.GetBytes(p));
            XsltPackage pp = xsltCompiler.CompilePackage(ms);
            xsltCompiler.ImportPackage(pp);
            XsltExecutable exec = xsltCompiler.Compile(new StringReader(s));
            Xslt30Transformer transf = exec.Load30();
            XdmDestination dest = new XdmDestination(); 
            transf.CallTemplate(null, dest);
            Console.WriteLine(dest.XdmNode);
                
            
        }
}
Actions #1

Updated by Michael Kay almost 6 years ago

  • Project changed from Saxon-CE to Saxon
  • Assignee set to Michael Kay
Actions #2

Updated by Michael Kay almost 6 years ago

  • Is duplicate of Bug #4035: Exporting a stylesheet containing node-valued static variables added
Actions #3

Updated by Michael Kay almost 6 years ago

  • Applies to branch 9.9, trunk added

Issue #4035 discusses the fact that we have a general problem exporting a package in which there are node-valued static variables.

The fact that we now have a concrete example of the problem will give added urgency to finding a solution, so thanks for submitting it.

Actions #4

Updated by Michael Kay almost 6 years ago

Reproduced as unit test s9apiTests/testPackage/testBug4117 (currently on the 10.0 branch only)

Actions #5

Updated by Michael Kay almost 6 years ago

This bug actually has nothing to do with #4035, because the failure occurs BEFORE the package export.

What actually seems to be happening here is that the function call to kw:get-keyword-value() is being inlined, but the function body contains a reference to a non-public variable which is not visible at the point of the function call.

Actions #6

Updated by Michael Kay almost 6 years ago

The simplest fix here is to disallow function inlining when the function call and the called function are in different packages.

(At present, when we export a package, we always export it together with all its dependencies. But we can envisage exporting a package without its dependencies and fixing these up later at link time, allowing the called package to be modified and recompiled; in that situation, inlining functions in the calling package would throw a spanner in the works. In the current model, inlining a function from a different package is possible in theory, but it raises all kinds of complications in getting the 'current component' right for bindings to other components, so it wouldn't be an easy fix.)

Actions #7

Updated by Michael Kay almost 6 years ago

  • Is duplicate of deleted (Bug #4035: Exporting a stylesheet containing node-valued static variables)
Actions #8

Updated by Michael Kay almost 6 years ago

  • Subject changed from java.lang.AssertionError : Target of component reference variable keywords is undefined to java.lang.AssertionError : Target of component reference variable keywords is undefined (caused by inlining function calls across a package boundary)
  • Description updated (diff)
  • Status changed from New to Resolved
  • Fix Committed on Branch 9.9, trunk added

Resolved as suggested, by disallowing inlining of functions in a different package.

Actions #9

Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.1.2 added

Bug issue fixed in the Saxon 9.9.1.2 maintenance release.

Please register to edit this issue

Also available in: Atom PDF