Commit ddadc31
src: rethrow stack overflow exceptions in async_hooks
When a stack overflow exception occurs during async_hooks callbacks
(which use TryCatchScope::kFatal), detect the specific "Maximum call
stack size exceeded" RangeError and re-throw it instead of immediately
calling FatalException. This allows user code to catch the exception
with try-catch blocks instead of requiring uncaughtException handlers.
The implementation adds IsStackOverflowError() helper to detect stack
overflow RangeErrors and re-throws them in TryCatchScope destructor
instead of calling FatalException.
This fixes the issue where async_hooks would cause stack overflow
exceptions to exit with code 7 (kExceptionInFatalExceptionHandler)
instead of being catchable.
Fixes: #37989
Ref: https://hackerone.com/reports/3456295
PR-URL: nodejs-private/node-private#773
Refs: https://hackerone.com/reports/3456295
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
CVE-ID: CVE-2025-594661 parent 6b48495 commit ddadc31Copy full SHA for ddadc31
File tree
Expand file treeCollapse file tree
10 files changed
+306
-14
lines changedOpen diff view settings
Filter options
- src
- test/parallel
Expand file treeCollapse file tree
10 files changed
+306
-14
lines changedOpen diff view settings
Collapse file
+6-3Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | | - |
| 71 | + |
| 72 | + |
72 | 73 | |
73 | 74 | |
74 | 75 | |
| ||
97 | 98 | |
98 | 99 | |
99 | 100 | |
100 | | - |
| 101 | + |
| 102 | + |
101 | 103 | |
102 | 104 | |
103 | 105 | |
| ||
646 | 648 | |
647 | 649 | |
648 | 650 | |
649 | | - |
| 651 | + |
| 652 | + |
650 | 653 | |
651 | 654 | |
652 | 655 | |
|
Collapse file
+2-1Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
333 | 333 | |
334 | 334 | |
335 | 335 | |
336 | | - |
| 336 | + |
| 337 | + |
337 | 338 | |
338 | 339 | |
339 | 340 | |
|
Collapse file
+63-8Lines changed: 63 additions & 8 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
194 | 194 | |
195 | 195 | |
196 | 196 | |
197 | | - |
| 197 | + |
198 | 198 | |
199 | 199 | |
200 | 200 | |
| ||
222 | 222 | |
223 | 223 | |
224 | 224 | |
225 | | - |
226 | | - |
227 | | - |
228 | 225 | |
229 | 226 | |
230 | 227 | |
| ||
299 | 296 | |
300 | 297 | |
301 | 298 | |
302 | | - |
| 299 | + |
| 300 | + |
303 | 301 | |
304 | 302 | |
305 | 303 | |
| ||
671 | 669 | |
672 | 670 | |
673 | 671 | |
| 672 | + |
| 673 | + |
| 674 | + |
| 675 | + |
| 676 | + |
| 677 | + |
| 678 | + |
| 679 | + |
| 680 | + |
| 681 | + |
| 682 | + |
| 683 | + |
| 684 | + |
| 685 | + |
| 686 | + |
| 687 | + |
| 688 | + |
| 689 | + |
| 690 | + |
| 691 | + |
| 692 | + |
| 693 | + |
| 694 | + |
| 695 | + |
| 696 | + |
| 697 | + |
| 698 | + |
| 699 | + |
674 | 700 | |
675 | 701 | |
676 | 702 | |
677 | | - |
| 703 | + |
678 | 704 | |
679 | 705 | |
680 | 706 | |
| 707 | + |
| 708 | + |
| 709 | + |
| 710 | + |
| 711 | + |
| 712 | + |
| 713 | + |
| 714 | + |
| 715 | + |
| 716 | + |
| 717 | + |
681 | 718 | |
682 | 719 | |
683 | 720 | |
| ||
1278 | 1315 | |
1279 | 1316 | |
1280 | 1317 | |
1281 | | - |
1282 | | - |
| 1318 | + |
| 1319 | + |
| 1320 | + |
| 1321 | + |
| 1322 | + |
| 1323 | + |
| 1324 | + |
| 1325 | + |
| 1326 | + |
| 1327 | + |
| 1328 | + |
| 1329 | + |
| 1330 | + |
| 1331 | + |
| 1332 | + |
| 1333 | + |
| 1334 | + |
| 1335 | + |
| 1336 | + |
| 1337 | + |
1283 | 1338 | |
1284 | 1339 | |
1285 | 1340 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
312 | 312 | |
313 | 313 | |
314 | 314 | |
315 | | - |
| 315 | + |
316 | 316 | |
317 | 317 | |
318 | 318 | |
|
Collapse file
+2-1Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
470 | 470 | |
471 | 471 | |
472 | 472 | |
473 | | - |
| 473 | + |
| 474 | + |
474 | 475 | |
475 | 476 | |
476 | 477 | |
|
Collapse file
test/parallel/test-async-hooks-stack-overflow-nested-async.js
Copy file name to clipboard+80Lines changed: 80 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 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
Collapse file
test/parallel/test-async-hooks-stack-overflow-try-catch.js
Copy file name to clipboard+47Lines changed: 47 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 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
Collapse file
test/parallel/test-async-hooks-stack-overflow.js
Copy file name to clipboard+47Lines changed: 47 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 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
Collapse file
test/parallel/test-uncaught-exception-handler-stack-overflow-on-stack-overflow.js
Copy file name to clipboard+29Lines changed: 29 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 | + |
0 commit comments