Followup-For: Bug #750593 I spent some time looking at what happens in the specific instance of the smb.conf.5 document. The docbook-xsl stylesheets do a global search-and-replace on the generated manpage: this is done recursively using the string.subst template. Eventually for long enough documents with sufficient matches it will hit implementation limits, whatever they are.
The attached patch against docbook-xsl modifies string.subst to use the EXSLT 'replace' function when it is available (it is in xsltproc). With this change the crash no longer occurs on i386. Output is identical on the smb.conf manpage and generating it is noticeably faster. I did not test other documents or architectures. -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.16-3-amd64 (SMP w/4 CPU cores) Locale: LANG=nl_BE.UTF-8, LC_CTYPE=nl_BE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages xsltproc depends on: ii libc6 2.19-13 ii libxml2 2.9.2+dfsg1-1 ii libxslt1.1 1.1.28-2+b2 xsltproc recommends no packages. xsltproc suggests no packages. -- no debconf information
Description: use EXSLT "replace" function when available A recursive implementation of string.subst is problematic, long strings with many matches will cause stack overflows. Author: Peter De Wachter <pdewa...@gmail.com> Bug-Debian: https://bugs.debian.org/750593 --- docbook-xsl-1.78.1+dfsg.orig/docbook-xsl/lib/lib.xsl +++ docbook-xsl-1.78.1+dfsg/docbook-xsl/lib/lib.xsl @@ -10,7 +10,10 @@ This module implements DTD-independent functions ******************************************************************** --> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:str="http://exslt.org/strings" + exclude-result-prefixes="str" + version="1.0"> <xsl:template name="dot.count"> <!-- Returns the number of "." characters in a string --> @@ -56,6 +59,9 @@ <xsl:param name="replacement"/> <xsl:choose> + <xsl:when test="function-available('str:replace')"> + <xsl:value-of select="str:replace($string, string($target), string($replacement))"/> + </xsl:when> <xsl:when test="contains($string, $target)"> <xsl:variable name="rest"> <xsl:call-template name="string.subst">