You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2014/12/26 12:52:28 UTC

ant git commit: Try to reduce the risk of StackOverflow/OOM in junitereport Submitted by: Ryan Bennitt Bugzilla: https://issues.apache.org/bugzilla/show_bug.cgi?id=57341

Repository: ant
Updated Branches:
  refs/heads/master a3125e6e7 -> f7f5327d2


Try to reduce the risk of StackOverflow/OOM in junitereport
Submitted by: Ryan Bennitt
Bugzilla: https://issues.apache.org/bugzilla/show_bug.cgi?id=57341


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/f7f5327d
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/f7f5327d
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/f7f5327d

Branch: refs/heads/master
Commit: f7f5327d28d67931c460290aab49eda4df92c2b4
Parents: a3125e6
Author: Stefan Bodewig <bo...@apache.org>
Authored: Fri Dec 26 12:41:54 2014 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Dec 26 12:46:24 2014 +0100

----------------------------------------------------------------------
 CONTRIBUTORS               |  1 +
 WHATSNEW                   |  5 +++++
 contributors.xml           |  4 ++++
 src/etc/junit-frames.xsl   | 19 ++++++++++++++++++-
 src/etc/junit-noframes.xsl | 19 ++++++++++++++++++-
 5 files changed, 46 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/f7f5327d/CONTRIBUTORS
----------------------------------------------------------------------
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index d83a683..ea7c3e0 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -330,6 +330,7 @@ Roger Vaughn
 Roman Ivashin
 Ronen Mashal
 Russell Gold
+Ryan Bennitt
 Sam Ruby
 Sandra Metz
 Scott Carlson

http://git-wip-us.apache.org/repos/asf/ant/blob/f7f5327d/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index e6a0b1b..ea3f75a 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -55,6 +55,11 @@ Fixed bugs:
  * complete-ant-cmd.pl now also knows about the -file option.
    Bugzilla Report 57371
 
+ * the br-replace template inside the XSLT stylesheets used by
+   <junitreport> could cause stack overflows or out-of-memory errors
+   when applied to big outputs.
+   Bugzilla Report 57341
+
 Other changes:
 --------------
 

http://git-wip-us.apache.org/repos/asf/ant/blob/f7f5327d/contributors.xml
----------------------------------------------------------------------
diff --git a/contributors.xml b/contributors.xml
index 3ce31a5..ae1e6fc 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -1334,6 +1334,10 @@
     <last>Gold</last>
   </name>
   <name>
+    <first>Ryan</first>
+    <last>Bennitt</last>
+  </name>
+  <name>
     <first>Sam</first>
     <last>Ruby</last>
   </name>

http://git-wip-us.apache.org/repos/asf/ant/blob/f7f5327d/src/etc/junit-frames.xsl
----------------------------------------------------------------------
diff --git a/src/etc/junit-frames.xsl b/src/etc/junit-frames.xsl
index 25fcf1f..afea6e0 100644
--- a/src/etc/junit-frames.xsl
+++ b/src/etc/junit-frames.xsl
@@ -929,7 +929,24 @@ h6 {
 -->
 <xsl:template name="br-replace">
     <xsl:param name="word"/>
+    <xsl:param name="splitlimit">32</xsl:param>
+    <xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/>
+    <xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/>
+    <!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string -->
     <xsl:choose>
+      <xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '&#xa;'))">
+        <xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '&#xa;')"/>
+        <xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/>
+        <xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/>
+        <xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '&#xa;')"/>
+        <xsl:call-template name="br-replace">
+            <xsl:with-param name="word" select="concat($firsthalfword,$firsthalfend)"/>
+        </xsl:call-template>
+        <br/>
+        <xsl:call-template name="br-replace">
+            <xsl:with-param name="word" select="$secondhalfend"/>
+        </xsl:call-template>
+      </xsl:when>
       <xsl:when test="contains($word, '&#xa;')">
         <xsl:value-of select="substring-before($word, '&#xa;')"/>
         <br/>
@@ -938,7 +955,7 @@ h6 {
         </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
-	<xsl:value-of select="$word"/>
+        <xsl:value-of select="$word"/>
       </xsl:otherwise>
     </xsl:choose>
 </xsl:template>

http://git-wip-us.apache.org/repos/asf/ant/blob/f7f5327d/src/etc/junit-noframes.xsl
----------------------------------------------------------------------
diff --git a/src/etc/junit-noframes.xsl b/src/etc/junit-noframes.xsl
index ab9e143..bd7002a 100644
--- a/src/etc/junit-noframes.xsl
+++ b/src/etc/junit-noframes.xsl
@@ -469,7 +469,24 @@
 -->
 <xsl:template name="br-replace">
     <xsl:param name="word"/>
+    <xsl:param name="splitlimit">32</xsl:param>
+    <xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/>
+    <xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/>
+    <!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string -->
     <xsl:choose>
+      <xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '&#xa;'))">
+        <xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '&#xa;')"/>
+        <xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/>
+        <xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/>
+        <xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '&#xa;')"/>
+        <xsl:call-template name="br-replace">
+          <xsl:with-param name="word" select="concat($firsthalfword,$firsthalfend)"/>
+        </xsl:call-template>
+        <br/>
+        <xsl:call-template name="br-replace">
+          <xsl:with-param name="word" select="$secondhalfend"/>
+        </xsl:call-template>
+      </xsl:when>
       <xsl:when test="contains($word, '&#xa;')">
         <xsl:value-of select="substring-before($word, '&#xa;')"/>
         <br/>
@@ -478,7 +495,7 @@
         </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
-	<xsl:value-of select="$word"/>
+        <xsl:value-of select="$word"/>
       </xsl:otherwise>
     </xsl:choose>
 </xsl:template>