segmentation fault on "xsltApplyXSLTTemplate: A potential infinite template recursion was detected"

Bug #988289 reported by pablo trukhanov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Medium
scoder

Bug Description

I cant easily reproduce it, because it happens only on highload (apache benchmark on our github.com/hhru/frontik with infinite template recursion XSL in threads)
if any info i can provide - just ask please.

$ dpkg -l python-lxml libxslt1.1 libxml2
ii python-lxml 2.3-4~my-1build1 pythonic binding for the libxml2 and libxslt libraries
ii libxslt1.1 1.1.26-1ubuntu1 XSLT processing library - runtime library
ii libxml2 2.7.6.dfsg-1ubuntu1.3

Python : (2, 6, 5, 'final', 0)
lxml.etree : (2, 3, 4, 0)
libxml used : (2, 7, 6)
libxml compiled : (2, 7, 6)
libxslt used : (1, 1, 26)
libxslt compiled : (1, 1, 26)

$ uname -a
Linux my 2.6.32-37-server #81-Ubuntu SMP Fri Dec 2 20:49:12 UTC 2011 x86_64 GNU/Linux

$ python -V
Python 2.6.5

gdb bt:

#0 0x00007ffff5e1f264 in __pyx_f_4lxml_5etree__forwardError (__pyx_v_c_log_handler=0x7fffec297f00, __pyx_v_error=0x7ffff171eab0) at src/lxml/lxml.etree.c:30765
#1 0x00007ffff5e1f5a7 in __pyx_f_4lxml_5etree__receiveXSLTError (__pyx_v_c_log_handler=0x7fffec297f00, __pyx_v_msg=0x7ffff5b8fd97 "Templates:\n") at src/lxml/lxml.etree.c:31276

python trace (if no segfault):

File "/.../head.xsl", line 7, column 0
runtime error, element 'apply-templates'
File "<string>", line 0, column 0
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).
File "<string>", line 0, column 0
........
File "<string>", line 0, column 0

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/tornado/web.py", line 880, in wrapper
    return callback(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/frontik/handler.py", line 303, in wrapper
    callback(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/frontik/handler_xml.py", line 225, in exception_cb
    raise e
XSLTApplyError: Error applying stylesheet

Revision history for this message
pablo trukhanov (pavel-trukhanov) wrote :

i can alse reproduce it on python-lxml=2.2.4-1

Revision history for this message
scoder (scoder) wrote :

It's not impossible that this is really due to the "xsltMaxDepth" setting being too low. The recursion depth is data dependent after all, so deeply recursive stylesheet calls could end up being blocked.

Sadly, the setting is a global variable in libxslt, so it's impossible to change it on a case-by-case basis in lxml. In the worst case, you can change it statically in libxslt's transform.c when you build it from sources.

For lxml 2.4, I'll add a method "XSLT.set_global_max_depth()" that you can use to change this setting globally.

scoder (scoder)
Changed in lxml:
assignee: nobody → Stefan Behnel (scoder)
importance: Undecided → Medium
milestone: none → 2.4
status: New → Fix Committed
Revision history for this message
scoder (scoder) wrote :

Fixed in lxml 3.0 alpha 1.

Changed in lxml:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.