Bug 67310

Summary: XSLTProcessor fails on a large XML document, hitting maxdepth limit
Product: WebKit Reporter: Dustin <at88mph>
Component: XMLAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Major CC: ap, mrowe
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.6   
See Also: https://bugs.webkit.org/show_bug.cgi?id=191075
https://bugs.webkit.org/show_bug.cgi?id=68701
Attachments:
Description Flags
Public astronomical XML file. Should be 2.9MB.
none
XSL File for the attached XML.
none
full test case (doesn't reproduce)
none
CORRECT XSL File! none

Description Dustin 2011-08-31 12:26:59 PDT
This is reproducible with Google Chrome 13.0.782.218 and Safari 5.1 on OS X 10.6, as well as Google Chrome 13.0.782.215 on Linux with kernel 3.0.0.  Safari 5.0.6 is not affected.

When using the JavaScript transformToDocument() method to transform a large XML file (> 2.1MB), it returns an undefined rather than a Document.  When using the transformToFragment() method it returns null.

The XML Document has a maximum depth of seven (7) and contains 85790 lines.

The attached XML file will reproduce it.  It contains public astronomical data.

Thank you.
Comment 1 Dustin 2011-08-31 12:27:58 PDT
Created attachment 105813 [details]
Public astronomical XML file.  Should be 2.9MB.
Comment 2 Alexey Proskuryakov 2011-08-31 16:21:24 PDT
Could you please attach your XSLT file, too?
Comment 3 Dustin 2011-09-01 10:27:57 PDT
Created attachment 105989 [details]
XSL File for the attached XML.

This is the XSL file.
Comment 4 Dustin 2011-09-01 10:33:36 PDT
// Small code sample of how it's being used.
//

var renderProcessor = new XSLTProcessor();
var renderXSLDOM = getXSLFromService(...);
var myDOM = getXMLFromService(...);

if (renderProcessor.reset)
{
  renderProcessor.reset();
}

try
{
  renderProcessor.importStylesheet(renderXSLDOM);

  // Set parameters...
  rederProcessor.setParameter(...);

  displayFragment = renderProcessor.transformToDocument(myDOM);
  
  // displayFragment is undefined.
}
catch (e1)
{
  alert("Found error! >> " + e1);
}
Comment 5 Alexey Proskuryakov 2011-09-01 10:58:24 PDT
Created attachment 105993 [details]
full test case (doesn't reproduce)

Thank you!

I tried to make an in-browser test case, but I cannot reproduce the problem in Safari 5.1 on Mac OS X Lion. I get an alert saying "[object Document]", so the result is not undefined.

Could you please take a look to find a difference with your case?
Comment 6 Dustin 2011-09-01 11:05:00 PDT
Created attachment 105994 [details]
CORRECT XSL File!

Sorry!  This is the correct XSL file.
Comment 7 Alexey Proskuryakov 2011-09-01 11:25:13 PDT
Just to confirm, is this transformation expected to work correctly without any parameters set?

I can reproduce a problem with the new xsl file (filter.xsl). Firefox quickly produces a document, while WebKit takes much longer, and shows "undefined".

I can also reproduce this error with command line libxslt utility on Mac OS X:

$ xsltproc filter.xsl data.xml
runtime error: file /Users/ap/.Trash/large-xsl/filter.xsl line 120 element param
xsltApplyXSLTTemplate: A potential infinite template recursion was detected.
You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).

This doesn't occur if I set maxdepth to 6000. Not sure if we should increase it.
Comment 8 Dustin 2011-09-01 11:43:37 PDT
First, thank you for the quick replies.  This is great.

renderProcessor.setParameter(null, "pageStart", 1);
renderProcessor.setParameter(null, "pageEnd", 100);

These are the only two parameters set for this.

Thanks for the xsltproc command.  That will help debug.

Dustin
Comment 9 Dustin 2011-09-06 09:59:12 PDT
Hi Alexey,

I'm not sure how to work around this.  The issue could be with the XSL file itself, to be fair, but I was just wondering where this ticket was left.  I'm still debugging this too.

Many thanks,
Dustin
Comment 10 Alexey Proskuryakov 2011-09-06 10:27:42 PDT
It's fairly unlikely that any further action on this bug will happen very soon.

I suggest asking on an XSL users mailing list for workaround ideas (unfortunately, I don't have specific pointers). It's indeed possible that a small modification of the stylesheet would avoid hitting this problem.
Comment 11 Dustin 2011-09-06 14:49:56 PDT
I will.  Thanks, Alexey.

Dustin