Closed Bug 632024 Opened 13 years ago Closed 13 years ago

Reflect.parse(Array(1000).join("x + y - ") + "z") crashes with stack overflow

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: dherman)

Details

(Whiteboard: reflect-parse fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

js_EmitTree can't compile that expression either, but it manage to avoid crashing by calling JS_CHECK_RECURSION.
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
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
Attached patch ohai JS_CHECK_RECURSION (obsolete) — Splinter Review
Jason, if you have a chance could you test this patch on your Windows machine? I will also run it through tryserver.

Thanks,
Dave
Assignee: general → dherman
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
Whiteboard: reflect-parse
Patch had gone stale; updated.

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

Thanks,
Dave
Attachment #511445 - Attachment is obsolete: true
Attachment #537796 - Flags: feedback?(jorendorff)
Comment on attachment 537796 [details] [diff] [review]
refreshed stale patch

Review of attachment 537796 [details] [diff] [review]:
-----------------------------------------------------------------
Attachment #537796 - Flags: feedback?(jorendorff) → review+
It works on my machine.

js> Reflect.parse(Array(1000).join("x + y - ") + "z")
typein:1: InternalError: too much recursion
http://hg.mozilla.org/tracemonkey/rev/0cc25c98d38e
Whiteboard: reflect-parse → reflect-parse fixed-in-tracemonkey
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: