I get a StackOverflowError when trying to run the test at: http://download.oddlabs.com/elias/classpathxml.tar.gz The test is a larger program pruned as much as possible while still demonstrating the stack overflow. Steps to reproduce: 1. Use Classpath CVS HEAD 2. Use either JamVM 1.4.3 or the Jikes RVM from SVN 3. Run the run.sh script from the test. I've noticed that turning off validation (the line containing factory.setValidating(true)) the test will run successfully. It seems that the validator stack depth is dependent on the number of child nodes (the <b/> nodes in this case), which is unfortunate.
Created attachment 12236 [details] test program
The stack overflow appears to be occurring in the regex code rather than anything inherent in the deisgn of the validation code. Ito, perhaps you could have a look at this?
I have confirmed that this problem is caused by the regex engine. Running the following simple program with the command like "java L 3000" will show the problem: import java.util.regex.*; public class L { public static void main(String[] args) throws Exception { Pattern p = Pattern.compile("(b)+"); int n = Integer.parseInt(args[0]); StringBuffer sb = new StringBuffer(); for (int i = 0; i < n; i++) { sb.append("b"); } Matcher m = p.matcher(sb); m.matches(); } } gnu.java.util.regex.RETokenRepeated uses a recursive call to find a match, and the longer the match is, the deeper the recursive call goes.
Changed the Component and Summary.
Subject: Bug 29047 CVSROOT: /cvsroot/classpath Module name: classpath Changes by: Ito Kazumitsu <itokaz> 06/09/22 21:36:36 Modified files: . : ChangeLog gnu/java/util/regex: RETokenRepeated.java Log message: 2006-09-22 Ito Kazumitsu <kaz@maczuka.gcd.org> Fixes bug #29047 * gnu/java/util/regex/RETokenRepeated.java (findMatch): Rewriten without using recursive calls, (FindMatchControlStack): New class, (FindMatchControl): New class, (TryAnotherResult): New class, (tryAnother): New method. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.8595&r2=1.8596 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/util/regex/RETokenRepeated.java?cvsroot=classpath&r1=1.2&r2=1.3
I have fixed the bug, and my simple test program now passes. Elias, could you please test your case? I cannot run it because my VM, Kaffe on FreeBSD, is not fully functional now.
Yes, the stack overlfow is gone with Classpath CVS HEAD. Thanks alot! - elias