Skip to content

Commit 3e1053e

Browse files
Stephen Belangertargos
Stephen Belanger
authored andcommitted
deps: V8: cherry-pick 81814ed44574
Original commit message: [promise] Avoid stack overflow with context promise hooks in C++ This was handled in JS but not in C++. Bug: chromium:236703, v8:11025 Change-Id: Ic9adc4ceb4d2af2614427fec459c3e950654572f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3074460 Commit-Queue: Camillo Bruni <[email protected]> Reviewed-by: Victor Gomes <[email protected]> Cr-Commit-Position: refs/heads/master@{#76125} Refs: v8/v8@81814ed PR-URL: #39719 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent d9d0104 commit 3e1053e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.7',
39+
'v8_embedder_string': '-node.8',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/objects/contexts.cc

+9-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,15 @@ void NativeContext::RunPromiseHook(PromiseHookType type,
525525

526526
Handle<Object> receiver = isolate->global_proxy();
527527

528-
if (Execution::Call(isolate, hook, receiver, argc, argv).is_null()) {
528+
StackLimitCheck check(isolate);
529+
bool failed = false;
530+
if (check.HasOverflowed()) {
531+
isolate->StackOverflow();
532+
failed = true;
533+
} else {
534+
failed = Execution::Call(isolate, hook, receiver, argc, argv).is_null();
535+
}
536+
if (failed) {
529537
DCHECK(isolate->has_pending_exception());
530538
Handle<Object> exception(isolate->pending_exception(), isolate);
531539

deps/v8/test/mjsunit/promise-hooks.js

+8
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,11 @@ exceptions();
273273

274274
d8.promise.setHooks();
275275
})();
276+
277+
(function overflow(){
278+
d8.promise.setHooks(() => { new Promise(()=>{}) });
279+
// Trigger overflow from JS code:
280+
Promise.all([Promise.resolve(1)]);
281+
%PerformMicrotaskCheckpoint();
282+
d8.promise.setHooks();
283+
});

0 commit comments

Comments
 (0)