Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Issue 1023483003: Parser: Fix crash on stack overflow when lazy-parsing arrow functions (Closed)

Created:
5 years, 9 months ago by aperez
Modified:
5 years, 9 months ago
CC:
v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Parser: Fix crash on stack overflow when lazy-parsing arrow functions The problem manifests itself when parsing manages to return something meaningful in the presence of a stack overflow. This happens because calling ParserBase::Next() will still return one valid token on stack overflow, before starting to return invalid tokens. Take the following input as example: a.map(v => v + 1); | | already next token parsed (which will be an invalid token (identifier) because of a stack overflow) The "v" may have been already parsed into a VariableProxy, then if a stack overflow occurs, next token will be an invalid token (instead of Token::ARROW), but the parser will return the VariableProxy. This always happens when lazy-parsing arrow functions, so the position in the input stream where the the arrow function code ends is known. This fix adds a check that ensures that parsing ended at the end position of the arrow function. BUG=465671 LOG=N Committed: https://crrev.com/3c3ce1bca831c03feab9c8fbfe95edd3c0e0447e Cr-Commit-Position: refs/heads/master@{#27325}

Patch Set 1 #

Total comments: 4

Patch Set 2 : Add parenthesized version test, comment on expected result #

Total comments: 2

Patch Set 3 : Fix nits as per review comments #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+34 lines, -10 lines) Patch
M src/parser.cc View 1 2 1 chunk +18 lines, -2 lines 1 comment Download
A + test/mjsunit/regress/regress-crbug-465671.js View 1 chunk +8 lines, -4 lines 0 comments Download
A + test/mjsunit/regress/regress-crbug-465671-null.js View 1 1 chunk +8 lines, -4 lines 0 comments Download

Messages

Total messages: 25 (3 generated)
aperez
5 years, 9 months ago (2015-03-18 22:11:38 UTC) #2
wingo
Non-OWNER LGTM. Please add a test for the parenthesized version as well -- i.e. (x)=>x+1 ...
5 years, 9 months ago (2015-03-19 07:48:45 UTC) #3
marja
https://codereview.chromium.org/1023483003/diff/1/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1023483003/diff/1/src/parser.cc#newcode1149 src/parser.cc:1149: // Scanning must end at the same position that ...
5 years, 9 months ago (2015-03-19 11:00:26 UTC) #4
aperez
On 2015/03/19 11:00:26, marja wrote: > https://codereview.chromium.org/1023483003/diff/1/src/parser.cc > File src/parser.cc (right): > > https://codereview.chromium.org/1023483003/diff/1/src/parser.cc#newcode1149 > ...
5 years, 9 months ago (2015-03-19 12:23:07 UTC) #5
aperez
The patch only needs to cover the case of lazy parsing. I have checked eager ...
5 years, 9 months ago (2015-03-19 12:42:30 UTC) #6
wingo
Still non-owner LGTM with a nit and a question On 2015/03/19 12:42:30, aperez wrote: > ...
5 years, 9 months ago (2015-03-19 13:21:40 UTC) #7
marja
On 2015/03/19 13:21:40, wingo wrote: > I thought so too but to expand on what ...
5 years, 9 months ago (2015-03-19 13:44:57 UTC) #8
marja
Hmm, and is the reason why this doesn't occur for non-array functions that we still ...
5 years, 9 months ago (2015-03-19 14:01:50 UTC) #9
wingo
On 2015/03/19 14:01:50, marja wrote: > Hmm, and is the reason why this doesn't occur ...
5 years, 9 months ago (2015-03-19 14:14:15 UTC) #10
marja
Ah okay, then this might actually be the right thing, and the thing above is ...
5 years, 9 months ago (2015-03-19 14:15:48 UTC) #11
marja
Nah, I reviewed it after all, lgtm, but pls add a comment along the lines ...
5 years, 9 months ago (2015-03-19 14:19:18 UTC) #12
aperez
On 2015/03/19 14:19:18, marja wrote: > Nah, I reviewed it after all, lgtm, but pls ...
5 years, 9 months ago (2015-03-19 23:55:32 UTC) #13
aperez
On 2015/03/19 13:21:40, wingo wrote: > Still non-owner LGTM with a nit and a question ...
5 years, 9 months ago (2015-03-19 23:57:25 UTC) #14
aperez
https://codereview.chromium.org/1023483003/diff/20001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1023483003/diff/20001/src/parser.cc#newcode1154 src/parser.cc:1154: // The input is known to be a function ...
5 years, 9 months ago (2015-03-19 23:57:39 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1023483003/40001
5 years, 9 months ago (2015-03-19 23:58:02 UTC) #18
commit-bot: I haz the power
Committed patchset #3 (id:40001)
5 years, 9 months ago (2015-03-20 00:17:48 UTC) #19
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/3c3ce1bca831c03feab9c8fbfe95edd3c0e0447e Cr-Commit-Position: refs/heads/master@{#27325}
5 years, 9 months ago (2015-03-20 00:18:01 UTC) #20
rossberg
On 2015/03/20 00:18:01, I haz the power (commit-bot) wrote: > Patchset 3 (id:??) landed as ...
5 years, 9 months ago (2015-03-20 10:03:48 UTC) #21
rossberg
On 2015/03/20 10:03:48, rossberg wrote: > On 2015/03/20 00:18:01, I haz the power (commit-bot) wrote: ...
5 years, 9 months ago (2015-03-20 10:30:16 UTC) #22
aperez
On 2015/03/20 10:30:16, rossberg wrote: > On 2015/03/20 10:03:48, rossberg wrote: > > On 2015/03/20 ...
5 years, 9 months ago (2015-03-20 18:11:15 UTC) #23
marja
https://codereview.chromium.org/1023483003/diff/40001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1023483003/diff/40001/src/parser.cc#newcode1154 src/parser.cc:1154: // bodies, since there is no end token suck ...
5 years, 9 months ago (2015-03-23 10:56:32 UTC) #24
aperez
5 years, 9 months ago (2015-03-23 11:27:53 UTC) #25
Message was sent while issue was closed.
On 2015/03/23 10:56:32, marja wrote:
> https://codereview.chromium.org/1023483003/diff/40001/src/parser.cc
> File src/parser.cc (right):
> 
>
https://codereview.chromium.org/1023483003/diff/40001/src/parser.cc#newcode1154
> src/parser.cc:1154: // bodies, since there is no end token suck as "}" for
> normal
> ... unintentional swearing? :)

VERY unintentional, indeed. Fix here:
https://codereview.chromium.org/1022413003

Powered by Google App Engine
This is Rietveld 408576698