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

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: jorendorff, Assigned: dherman)

Tracking

Other Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

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

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

7 years ago
js_EmitTree can't compile that expression either, but it manage to avoid crashing by calling JS_CHECK_RECURSION.
(Assignee)

Comment 1

7 years ago
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
(Assignee)

Comment 2

7 years ago
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
(Assignee)

Comment 3

7 years ago
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
Assignee: general → dherman
(Assignee)

Comment 4

7 years ago
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
(Assignee)

Updated

7 years ago
Whiteboard: reflect-parse
(Assignee)

Comment 5

6 years ago
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
Attachment #511445 - Attachment is obsolete: true
Attachment #537796 - Flags: feedback?(jorendorff)
(Reporter)

Comment 6

6 years ago
Comment on attachment 537796 [details] [diff] [review]
refreshed stale patch

Review of attachment 537796 [details] [diff] [review]:
-----------------------------------------------------------------
Attachment #537796 - Flags: feedback?(jorendorff) → review+
(Reporter)

Comment 7

6 years ago
It works on my machine.

js> Reflect.parse(Array(1000).join("x + y - ") + "z")
typein:1: InternalError: too much recursion
(Assignee)

Comment 8

6 years ago
http://hg.mozilla.org/tracemonkey/rev/0cc25c98d38e
Whiteboard: reflect-parse → reflect-parse fixed-in-tracemonkey
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/0cc25c98d38e
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.