Issue Details (XML | Word | Printable)

Key: XALANJ-1243
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Henry Zongaro
Reporter: Wolfram
Votes: 3
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XalanJ2

java.lang.StackOverflowError in XString.equals()

Created: 22/Oct/02 10:36 PM   Updated: 11/Dec/07 04:57 PM
Return to search
Component/s: XPath
Affects Version/s: 2.7
Fix Version/s: 2.7.1

Time Tracking:
Not Specified

File Attachments:
  Size
XML File 1.xml 2003-10-02 09:36 PM Bruno Verachten 18 kB
XML File 1.xsl 2003-10-02 09:36 PM Bruno Verachten 9 kB
Text File Licensed for inclusion in ASF works patch.j1243.txt 2007-08-24 06:14 PM Henry Zongaro 4 kB
Zip Archive xalan-stack-overflow.zip 2004-01-22 11:23 PM Martini Roberto 2 kB
Environment:
Operating System: Solaris
Platform: Sun
Issue Links:
Duplicate
 
Reference

Bugzilla Id: 13851
Xalan info: PatchAvailable
Reviewer: Brian Minchau
Resolution Date: 27/Aug/07 01:33 PM


 Description  « Hide
In some special cases I get a StackOverflowError in method equals(XMLString),
line #444 [ if (!obj2.hasString()) return obj2.equals(this); ]

I think this can occur if to XStringForChars-objects are compared, and both
objects haven't been used before. Than the hasString()-method of
XStringForChars returns false for both, resulting in an endless loop.

I patched XStringForChars method hasString() to return always true,
which works for me.

Don't know if this is the right way to solve this bug.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Bruno Verachten added a comment - 02/Oct/03 09:36 PM
Created an attachment (id=8430)
An XML file to be processed with 1.xsl

Bruno Verachten added a comment - 02/Oct/03 09:36 PM
Created an attachment (id=8431)
The xsl file to apply to 1.xml

Oliver Gries added a comment - 19/Jan/04 10:06 PM
Just let a potential XString object initialize itself in the equals() method of
XString, e.g. like:


public boolean equals(XMLString obj2)
{

  if (!obj2.hasString())
  {
    // **** new code start ****
    this.str();
    // **** new code end ****
    return obj2.equals(this);
  }
  else
    return str().equals(obj2.toString());
}

I don't know about performance for this test. We got this Stackoverflow several
times.

Martini Roberto added a comment - 22/Jan/04 11:23 PM
Created an attachment (id=10055)
Bug replication

Stuart A. Malone added a comment - 16/Apr/04 02:24 AM
I ran into this bug doing XSLT processing both in Cocoon and in Ant. My fix was to remove the
"optimization" in XString.equals so that it reads:

public boolean equals(XMLString obj2)
{
      return str().equals(obj2.toString());
}

This was particularly nasty for me because Apple includes this class in /System/Library/Frameworks/
JavaVM.framework/Versions/1.4.2/Classes/classes.jar, which is in the baseclasspath and is tricky to
override.

Henry Zongaro added a comment - 19/Dec/06 03:05 PM
I just happened to notice that all four of these issues (XALANJ-1243, XALANJ-1880, XALANJ-1991 and XALANJ-2001) appear to be related to one another because they all seem to describe the same problem with XString.equals, but I haven't investigated further to be certain of that, so I just thought I'd provide that information. XALANJ-2001 contains a patch that avoids the problem, but I didn't like the patch at the same, so it's never been applied.

Henry Zongaro added a comment - 24/Aug/07 06:14 PM
Attaching a patch that I believe resolves this problem.

Brian Minchau added a comment - 26/Aug/07 02:23 PM
I have reviewed Henry Zongaro's patch an approve it.

Henry Zongaro added a comment - 27/Aug/07 01:33 PM
Applied patch to Subversion repository.

Brian Minchau added a comment - 11/Dec/07 03:24 PM
Changing affected version to 2.7, and fixed version to 2.7.1

Brian Minchau added a comment - 11/Dec/07 04:57 PM
Would the originator of this issue please verify that this issue is fixed in the 2.7.1 release, by adding a comment to this issue, so that we can close this issue.

A lack of response by February 1, 2008 will be taken as consent that we can close this resolved issue.

Regards,
Brian Minchau