I encountered an occasional StackOverflowError in the following method:
com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy.doActio
n()
I found it was related to the following Pattern / Matcher and recreated it
outside of HtmlUnit (I will attach scriptText2.txt).
private static void matchTest() {
try {
BufferedReader reader = new BufferedReader(new
FileReader("scriptText2.txt"));
StringBuffer buffer = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
buffer.append(line + "\n");
}
int i = Pattern.CASE_INSENSITIVE;
Pattern pattern = Pattern.compile("<style\\b(\\s|.)*?<\\/style>", i);
Matcher matcher = pattern.matcher(buffer.toString());
System.out.println(matcher.find());
}
catch (StackOverflowError er) {
System.err.println("STACK OVERFLOW");
System.exit(0);
}
}
That code resulted in a StackOverflowError with no arguments passed to
Java, or if I forced a reasonably low stack size e.g. -Xss256k. Java's
behavior
seems deeply recursive here.
I found that increasing my java stack size ( -Xss1m ) resolved the issue,
but also found that, for my case I was able to take the newlines out of
"buffer" and
change my regex pattern to: <style\\b.*?<\\/style>
I realize that, in a sense, there is not a bug here or that, if there is,
it may be more an issue with Java's pattern matching, but thought it was
worth bringing
to your attention, as I imagine others might run into this issue. Sorry
that I have not tried it in the latest nightly build, unfortunately time
constraints
have not yet allowed me to do so.
I am using JRE1.6.0_17.
Nobody/Anonymous
None
2.6
Public
|
Date: 2009-11-05 18:45 Just tried it with JRE 1.5.0_22 and observed the StackOverflowError |
|
Date: 2009-11-05 11:48 Did you check it with Java 5? |
| Filename | Description | Download |
|---|---|---|
| scriptText2.txt | Sample text from actual js that causes StackOverflowError | Download |
| Field | Old Value | Date | By |
|---|---|---|---|
| File Added | 349567: scriptText2.txt | 2009-11-04 21:25 | ben-flynn |
Copyright © 2009 Geeknet, Inc. All rights reserved. Terms of Use