Commit c7d4ff3
repl: fix .load infinite loop caused by shared use of lineEnding RegExp
Since the lineEnding Regular Expression is declared on the module scope,
recursive invocations of its `[kTtyWrite]` method share one instance of
this Regular Expression.
Since the state of a RegExp is managed by instance,
alternately calling RegExpPrototypeExec with the same RegExp on
different strings can lead to the state changing unexpectedly.
This is the root cause of this infinite loop bug when calling .load on
javascript files of certain shapes.
PR-URL: #46742
Fixes: #46731
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>1 parent 132fc45 commit c7d4ff3Copy full SHA for c7d4ff3
File tree
Expand file treeCollapse file tree
2 files changed
+46
-9
lines changedOpen diff view settings
Filter options
- lib/internal/readline
- test/parallel
Expand file treeCollapse file tree
2 files changed
+46
-9
lines changedOpen diff view settings
Collapse file
lib/internal/readline/interface.js
Copy file name to clipboardExpand all lines: lib/internal/readline/interface.js+13-9Lines changed: 13 additions & 9 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1330 | 1330 | |
1331 | 1331 | |
1332 | 1332 | |
| 1333 | + |
| 1334 | + |
1333 | 1335 | |
1334 | | - |
1335 | | - |
1336 | | - |
1337 | | - |
1338 | | - |
| 1336 | + |
| 1337 | + |
| 1338 | + |
| 1339 | + |
| 1340 | + |
| 1341 | + |
| 1342 | + |
1339 | 1343 | |
1340 | 1344 | |
1341 | | - |
1342 | | - |
1343 | | - |
1344 | | - |
| 1345 | + |
| 1346 | + |
| 1347 | + |
| 1348 | + |
1345 | 1349 | |
1346 | 1350 | |
1347 | 1351 | |
|
Collapse file
test/parallel/test-readline-interface-recursive-writes.js
Copy file name to clipboard+33Lines changed: 33 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 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
0 commit comments