From d4ac4948e745ec83ed6c753bb21c711af7ecaa05 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 1 Dec 2021 00:58:16 +0800 Subject: [PATCH] src: use a higher limit in the NearHeapLimitCallback V8 requires the NearHeapLimitCallback to return a limit that's higher than the initial one or otherwise it will crash. --- src/env.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/env.cc b/src/env.cc index 2cb2dccdf32ba4..2e28d5aab6dd51 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1631,7 +1631,10 @@ size_t Environment::NearHeapLimitCallback(void* data, env->isolate()->AutomaticallyRestoreInitialHeapLimit(0.95); env->is_processing_heap_limit_callback_ = false; - return initial_heap_limit; + + // The new limit must be higher than initial_heap_limit or V8 might + // crash. + return initial_heap_limit + 1; } inline size_t Environment::SelfSize() const {