From: SourceForge.net <no...@so...> - 2009-12-12 18:02:06
|
Bugs item #1211477, was opened at 2005-05-30 10:21 Message generated for change (Comment added) made by bobstayton You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=373747&aid=1211477&group_id=21935 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: XSL Group: output: HTMLHelp/JavaHelp/EclipseHelp Status: Closed Resolution: Wont Fix Priority: 2 Private: No Submitted By: David Green (dgreen99) Assigned to: Nobody/Anonymous (nobody) Summary: HTML: docbook table with many rows causes StackOverflowError Initial Comment: Processing a docbook with a tbody that has many (about 700) rows causes a stack overflow error when using Xalan as the XSL processing engine. This problem appears to be related to recursion in table.xsl at line 616. An appropriate fix would be to avoid recursion when processing table rows. (I'm not sure why this is necessary) A portion of the stack trace follows: at org.apache.xpath.axes.BasicTestIterator.nextNode(BasicTestIterator.java:139) at org.apache.xpath.axes.NodeSequence.nextNode(NodeSequence.java:280) at org.apache.xpath.objects.XNodeSet.compare(XNodeSet.java:607) at org.apache.xpath.objects.XNodeSet.notEquals(XNodeSet.java:716) at org.apache.xpath.operations.NotEquals.operate(NotEquals.java:44) at org.apache.xpath.operations.Operation.execute(Operation.java:109) at org.apache.xpath.axes.PredicatedNodeTest.executePredicates(PredicatedNodeTest.java:339) at org.apache.xpath.axes.PredicatedNodeTest.acceptNode(PredicatedNodeTest.java:476) at org.apache.xpath.axes.AxesWalker.nextNode(AxesWalker.java:369) at org.apache.xpath.axes.WalkingIterator.nextNode(WalkingIterator.java:191) at org.apache.xpath.axes.NodeSequence.nextNode(NodeSequence.java:280) at org.apache.xpath.axes.NodeSequence.runTo(NodeSequence.java:434) at org.apache.xpath.axes.NodeSequence.setRoot(NodeSequence.java:217) at org.apache.xpath.axes.LocPathIterator.execute(LocPathIterator.java:211) at org.apache.xpath.XPath.execute(XPath.java:268) at org.apache.xalan.templates.ElemWithParam.getValue(ElemWithParam.java:200) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:225) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1917) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1839) at org.apache.xalan.templates.ElemWithParam.getValue(ElemWithParam.java:216) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:225) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1917) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1839) at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:311) at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:247) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:393) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:247) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:127) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1917) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1839) at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:311) at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:247) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:393) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:247) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1917) at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1839) at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:311) at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:247) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:393) at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:247) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:682) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemElement.constructNode(ElemElement.java:338) at org.apache.xalan.templates.ElemElement.execute(ElemElement.java:287) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:127) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:127) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:127) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:127) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:140) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:127) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) ---------------------------------------------------------------------- >Comment By: Robert Stayton (bobstayton) Date: 2009-12-12 10:02 Message: I checked in Eric Bishoff's patch to turn off row recursion if the table contains no morerows attributes. That will at least enable long tables that don't use morerows to process without running into the stack depth error. Still no solution for long tables with morerows. ---------------------------------------------------------------------- Comment By: Eric Bischoff (ebischoff) Date: 2007-08-11 12:26 Message: Logged In: YES user_id=340882 Originator: NO I request reopening of this bug. It is not resolved. It apparently affects all parsers I have tested. The problem can be a showstopper when big tables cannot be split. I have come with a solution : - Dynamically test if there are "morerow"s - if not, it's not necessary to recurse, a regular loop is enough This way the spans continue working when they exist, and tables go faster and safer when they don't. As I don't know how to attach the patch to this issue, I will send them in private to bob and norm. ---------------------------------------------------------------------- Comment By: Robert Stayton (bobstayton) Date: 2005-07-11 09:00 Message: Logged In: YES user_id=193218 Norm Walsh reviewed the necessity of using recursion in row processing. Here is his response: "If it didn't recurse through all the rows, then some of the rows wouldn't appear in the output :-) so, yes, it has to do them all. That code isn't looking at the following rows to calculate spans, it calculates the spans for this row and then processes the next row (using the span information that it just calculated). I've looked at this code a couple of times, the stack overflow was reported on the Saxon list originally I think, and I don't see any way to improve it. Maybe it could be done in two passes with less memory, but I'm not sure. The problem is that spans can "carry forward" an arbitrary distance so you sort of have to work your way through "remembering" what you've seen. For a really big table, that means you wind up deeply nested." -- Norm Walsh The conclusion is that the recursion is needed to process table entry spans, and cannot just be turned off. If your 700 row table does not use spans, you could insert a processing instruction into it, and write a customization of the row template to respond to that processing instruction to skip the span recursion. ---------------------------------------------------------------------- Comment By: Michael(tm) Smith (xmldoc) Date: 2005-06-21 19:05 Message: Logged In: YES user_id=118135 David, I'm not sure what to do with this issue. If you want, we can continue to keep it open, but I need to let you know that it is probably going to remain a very low priority -- both because it does not seem to be a problem in other XSLT engines (e.g., Saxon or xsltproc), only in Xalan, and because I don't think most users do not have a need to process tables that have 700+ rows. Also, any time a code change is made, there's always a risk of inadvertently introducing new bugs. In this case that risk may be greater than the benefit. FWIW, here are some personal suggestions for other ways to deal with the Xalan problem. - Break up your 700-row table into smaller tables. Instead of one 700-row table, make it two 350-row tables, or three 200+ row tables, or whatever. The thing is, if you have a table with more than 700 rows in your document, you are going to run into problems with applications (not just the DocBook XSL stylesheets). For example, have you attempted yet to get a PDF from the document in which you have that table, and has the XSL-FO engine (or whatever app you used) been able to process it without running out of memory or hanging or segfaulting or whatever? - Don't use Xalan. Relative to Saxon, in my experience, Xalan is buggy. I personally never use Xalan except for testing, and even then, I sometimes run into bugs that I can't work around or fix. We have had many DocBook XSL stylesheet bugs reported by users of Xalan that are not reproducible with Saxon. But we have never once (as far as I know) had a bug reported by a Saxon user that was not reproducible with other XSLT engines. And long with being basically bug-free, Saxon is (in my experience) faster than Xalan. So, anyway, unless you must use Xalan for some reason, I would recommend switching to Saxon. ---------------------------------------------------------------------- Comment By: David Green (dgreen99) Date: 2005-06-07 11:40 Message: Logged In: YES user_id=733416 I've reviewed this one a little more closely. It looks like the spans variable is used recursively (for all previous rows) to calculate the spans for the current row. I'm not exactly sure what spans is or how it should be used -- however my fix doesn't do this recursive calculation when iterating over the rows (it uses blank.spans instead.) I'm not clear on what the impact of this change would be. Can someone provide more clarity on what spans is and how it works? ---------------------------------------------------------------------- Comment By: Michael(tm) Smith (xmldoc) Date: 2005-06-01 19:27 Message: Logged In: YES user_id=118135 David: I tested this with Saxon and I get the following error: David, I had to back out your patch because when I tested with Saxon, I got the following error. Error at xsl:with-param on line 532 of file:/sandbox/xsl/html/table.xsl: Variable spans has not been declared Strangely, I did not get that error in testing with xsltproc. If possible, please test with Saxon as well as Xalan and provide a patch that you can confirm will work with Saxon too. Moving status for this issue back to Open. --Mike ---------------------------------------------------------------------- Comment By: David Green (dgreen99) Date: 2005-06-01 10:52 Message: Logged In: YES user_id=733416 Fantastic... thanks! ---------------------------------------------------------------------- Comment By: Michael(tm) Smith (xmldoc) Date: 2005-06-01 10:11 Message: Logged In: YES user_id=118135 I went ahead and committed the patch after smoke-testing it and not seeing any obvious problems with it. ---------------------------------------------------------------------- Comment By: David Green (dgreen99) Date: 2005-06-01 08:57 Message: Logged In: YES user_id=733416 Diff posted against HEAD. ---------------------------------------------------------------------- Comment By: Michael(tm) Smith (xmldoc) Date: 2005-06-01 03:52 Message: Logged In: YES user_id=118135 Please post a diff between your modified copy of table.xsl and the original table.xsl from the DocBook XSL stylesheets distribution that you tested with. ---------------------------------------------------------------------- Comment By: David Green (dgreen99) Date: 2005-05-30 10:42 Message: Logged In: YES user_id=733416 I've created an xsl containing templates for tbody and row. This resolves the problem with some trivial changes to the original templates. I've tested it on my docbook that was causing the problem and the problem has now gone away. The table with > 700 rows now works just fine. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=373747&aid=1211477&group_id=21935 |