[HtmlUnit] [ htmlunit-Bugs-2892191 ] StackOverflowError parsing JavaScript style tags

View: New views
1 Messages — Rating Filter:   Alert me  

[HtmlUnit] [ htmlunit-Bugs-2892191 ] StackOverflowError parsing JavaScript style tags

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bugs item #2892191, was opened at 2009-11-04 13:25
Message generated for change (Tracker Item Submitted) made by ben-flynn
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=2892191&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Benjamin Flynn (ben-flynn)
Assigned to: Nobody/Anonymous (nobody)
Summary: StackOverflowError parsing JavaScript style tags

Initial Comment:
I encountered an occasional StackOverflowError in the following method:

com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy.doAction()

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.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=2892191&group_id=47038

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop