From 52948a0b549f64fa7d129dc50fcbb6b9fbdd9c8f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 31 Aug 2021 11:16:45 +0200 Subject: [PATCH 1/2] src: use Isolate::TryGetCurrent where appropriate In two places, we call `Isolate::GetCurrent()` even though that is technically invalid usage of the function. Now that V8 exposes `Isolate::TryGetCurrent()`, we can do this in a proper way. --- src/node.cc | 2 +- src/node_errors.cc | 2 +- src/util.cc | 2 +- src/util.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node.cc b/src/node.cc index 3ee25ebbd67a01..acf4f0fac03c0b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -147,7 +147,7 @@ unsigned int reverted_cve = 0; // util.h // Tells whether the per-process V8::Initialize() is called and -// if it is safe to call v8::Isolate::GetCurrent(). +// if it is safe to call v8::Isolate::TryGetCurrent(). bool v8_initialized = false; // node_internals.h diff --git a/src/node_errors.cc b/src/node_errors.cc index 0e4ba26e1bcb70..3028892b0807e3 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -430,7 +430,7 @@ void OnFatalError(const char* location, const char* message) { FPrintF(stderr, "FATAL ERROR: %s\n", message); } - Isolate* isolate = Isolate::GetCurrent(); + Isolate* isolate = Isolate::TryGetCurrent(); Environment* env = nullptr; if (isolate != nullptr) { env = Environment::GetCurrent(isolate); diff --git a/src/util.cc b/src/util.cc index e181fdf568cd18..bae5a47a06d8de 100644 --- a/src/util.cc +++ b/src/util.cc @@ -128,7 +128,7 @@ BufferValue::BufferValue(Isolate* isolate, Local value) { void LowMemoryNotification() { if (per_process::v8_initialized) { - auto isolate = Isolate::GetCurrent(); + auto isolate = Isolate::TryGetCurrent(); if (isolate != nullptr) { isolate->LowMemoryNotification(); } diff --git a/src/util.h b/src/util.h index 050e4bda35a139..43dac02110adbf 100644 --- a/src/util.h +++ b/src/util.h @@ -91,7 +91,7 @@ inline T MultiplyWithOverflowCheck(T a, T b); namespace per_process { // Tells whether the per-process V8::Initialize() is called and -// if it is safe to call v8::Isolate::GetCurrent(). +// if it is safe to call v8::Isolate::TryGetCurrent(). extern bool v8_initialized; } // namespace per_process From 7f47ebfac5fbdf4c3478e1a84a03586927058345 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 31 Aug 2021 12:43:45 +0200 Subject: [PATCH 2/2] Revert "src: skip test_fatal/test_threads for Debug builds" This reverts commit 1fc4d43a3255273709f5fcb51bb0c5b0407de4ac. --- test/node-api/test_fatal/test_threads.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/node-api/test_fatal/test_threads.js b/test/node-api/test_fatal/test_threads.js index 6f6dc772d18252..fd56f60cbe832f 100644 --- a/test/node-api/test_fatal/test_threads.js +++ b/test/node-api/test_fatal/test_threads.js @@ -4,10 +4,6 @@ const assert = require('assert'); const child_process = require('child_process'); const test_fatal = require(`./build/${common.buildType}/test_fatal`); -if (common.buildType === 'Debug') - common.skip('as this will currently fail with a Debug check ' + - 'in v8::Isolate::GetCurrent()'); - // Test in a child process because the test code will trigger a fatal error // that crashes the process. if (process.argv[2] === 'child') {