Commit 32b9728
Segfault in JSC::IdentifierArena::makeBigIntDecimalIdentifier
https://bugs.webkit.org/show_bug.cgi?id=247644
rdar://98566429
Reviewed by Mark Lam and Yusuke Suzuki.
We currently get a segfault because the parser for bigdecimal identifiers allocates a JSBigInt, which
might cause us to run out of memory. The parser doesn't throw arbitrary exceptions elsewhere, so instead
of throwing out-of-memory as an exception, it just produces an empty JSBigInt and crashes when using it.
This patch addresses the issue by making the result of makeBigIntDecimalIdentifier nullable, checking for
it in the parser, and failing with a SyntaxError if the identifier could not be created.
* JSTests/stress/bigdecimal-identifiers-fail-on-oom.js: Added.
(foo):
* Source/JavaScriptCore/parser/Lexer.cpp:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseDestructuringPattern):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parseGetterSetter):
* Source/JavaScriptCore/parser/ParserArena.cpp:
(JSC::IdentifierArena::makeBigIntDecimalIdentifier):
* Source/JavaScriptCore/parser/ParserArena.h:
Canonical link: https://commits.webkit.org/256501@main1 parent 8900c3f commit 32b9728Copy full SHA for 32b9728
4 files changed
+40-11Lines changed: 40 additions & 11 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- JSTests/stress
- Source/JavaScriptCore/parser
Expand file treeCollapse file tree
Open diff view settings
Collapse file
JSTests/stress/bigdecimal-identifiers-fail-on-oom.js
Copy file name to clipboard+20Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
Collapse file
Source/JavaScriptCore/parser/Parser.cpp
Copy file name to clipboardExpand all lines: Source/JavaScriptCore/parser/Parser.cpp+10-7Lines changed: 10 additions & 7 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1316 | 1316 | |
1317 | 1317 | |
1318 | 1318 | |
1319 | | - |
| 1319 | + |
| 1320 | + |
1320 | 1321 | |
1321 | 1322 | |
1322 | 1323 | |
| ||
3054 | 3055 | |
3055 | 3056 | |
3056 | 3057 | |
3057 | | - |
3058 | | - |
| 3058 | + |
| 3059 | + |
3059 | 3060 | |
3060 | 3061 | |
3061 | 3062 | |
| ||
3316 | 3317 | |
3317 | 3318 | |
3318 | 3319 | |
3319 | | - |
3320 | | - |
| 3320 | + |
| 3321 | + |
3321 | 3322 | |
3322 | 3323 | |
3323 | 3324 | |
| ||
4613 | 4614 | |
4614 | 4615 | |
4615 | 4616 | |
4616 | | - |
| 4617 | + |
| 4618 | + |
4617 | 4619 | |
4618 | 4620 | |
4619 | 4621 | |
| ||
4705 | 4707 | |
4706 | 4708 | |
4707 | 4709 | |
4708 | | - |
| 4710 | + |
| 4711 | + |
4709 | 4712 | |
4710 | 4713 | |
4711 | 4714 | |
|
Collapse file
Source/JavaScriptCore/parser/ParserArena.cpp
Copy file name to clipboardExpand all lines: Source/JavaScriptCore/parser/ParserArena.cpp+9-3Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
79 | 79 | |
80 | 80 | |
81 | 81 | |
82 | | - |
| 82 | + |
83 | 83 | |
84 | 84 | |
85 | | - |
| 85 | + |
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | 91 | |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
92 | 98 | |
93 | 99 | |
94 | 100 | |
| ||
106 | 112 | |
107 | 113 | |
108 | 114 | |
109 | | - |
| 115 | + |
110 | 116 | |
111 | 117 | |
112 | 118 | |
|
Collapse file
Source/JavaScriptCore/parser/ParserArena.h
Copy file name to clipboardExpand all lines: Source/JavaScriptCore/parser/ParserArena.h+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | | - |
| 53 | + |
54 | 54 | |
55 | 55 | |
56 | 56 | |
|
0 commit comments