Last Comment Bug 632024 - Reflect.parse(Array(1000).join("x + y - ") + "z") crashes with stack overflow
: Reflect.parse(Array(1000).join("x + y - ") + "z") crashes with stack overflow
Status: RESOLVED FIXED
reflect-parse fixed-in-tracemonkey
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Other Branch
: All All
: -- normal (vote)
: ---
Assigned To: Dave Herman [:dherman]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-07 07:26 PST by Jason Orendorff [:jorendorff]
Modified: 2011-06-20 17:17 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
ohai JS_CHECK_RECURSION (4.91 KB, patch)
2011-02-10 10:54 PST, Dave Herman [:dherman]
no flags Details | Diff | Splinter Review
refreshed stale patch (4.89 KB, patch)
2011-06-07 08:25 PDT, Dave Herman [:dherman]
jorendorff: review+
Details | Diff | Splinter Review

Description Jason Orendorff [:jorendorff] 2011-02-07 07:26:08 PST
js_EmitTree can't compile that expression either, but it manage to avoid crashing by calling JS_CHECK_RECURSION.
Comment 1 Dave Herman [:dherman] 2011-02-07 16:54:44 PST
Couldn't reproduce on my MacOS machine at first, but fattening up my ASTSerializer::expression() frames with a 16KB array got it to reproduce, using

    Reflect.parse(Array(195).join("x + y - ") + "z")

Dave
Comment 2 Dave Herman [:dherman] 2011-02-07 17:05:12 PST
I need to audit this a little more carefully, but I think the main recursive entry points that need a JS_CHECK_RECURSION guard are:

    ASTSerializer::expression()
    ASTSerializer::statement()
    ASTSerializer::pattern()

and possibly

    ASTSerializer::declaration()

That last one may not be necessary. I'll post a patch soon.

Thanks,
Dave
Comment 3 Dave Herman [:dherman] 2011-02-10 10:54:04 PST
Created attachment 511445 [details] [diff] [review]
ohai JS_CHECK_RECURSION

Jason, if you have a chance could you test this patch on your Windows machine? I will also run it through tryserver.

Thanks,
Dave
Comment 4 Dave Herman [:dherman] 2011-02-10 10:56:04 PST
BTW, the patch adds JS_CHECK_RECURSION for the following entry points:

    ASTSerializer::expression()
    ASTSerializer::statement()
    ASTSerializer::pattern()
    ASTSerializer::xml()

It doesn't for ASTSerializer::declaration() or ASTSerializer::function() since those can only enter cycles by passing through ASTSerializer::statement() or ASTSerializer::expression().

Dave
Comment 5 Dave Herman [:dherman] 2011-06-07 08:25:42 PDT
Created attachment 537796 [details] [diff] [review]
refreshed stale patch

Patch had gone stale; updated.

Jason: can you test this for me on your Windows machine?

Thanks,
Dave
Comment 6 Jason Orendorff [:jorendorff] 2011-06-16 09:42:53 PDT
Comment on attachment 537796 [details] [diff] [review]
refreshed stale patch

Review of attachment 537796 [details] [diff] [review]:
-----------------------------------------------------------------
Comment 7 Jason Orendorff [:jorendorff] 2011-06-16 09:43:22 PDT
It works on my machine.

js> Reflect.parse(Array(1000).join("x + y - ") + "z")
typein:1: InternalError: too much recursion
Comment 8 Dave Herman [:dherman] 2011-06-16 23:28:38 PDT
http://hg.mozilla.org/tracemonkey/rev/0cc25c98d38e
Comment 9 Chris Leary [:cdleary] (not checking bugmail) 2011-06-20 17:17:18 PDT
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/0cc25c98d38e

Note You need to log in before you can comment on or make changes to this bug.