fix: don't run environment bootstrapper (#22342)
This commit is contained in:
parent
2aa734385e
commit
79270e30a6
14 changed files with 79 additions and 158 deletions
|
@ -22,7 +22,6 @@ refactor_allow_embedder_overriding_of_internal_fs_calls.patch
|
|||
chore_prevent_warn_non_context-aware_native_modules_being_loaded.patch
|
||||
inherit_electron_crashpad_pipe_name_in_child_process.patch
|
||||
chore_read_nobrowserglobals_from_global_not_process.patch
|
||||
chore_split_createenvironment_into_createenvironment_and.patch
|
||||
build_bring_back_node_with_ltcg_configuration.patch
|
||||
revert_crypto_add_oaeplabel_option.patch
|
||||
refactor_transferrablemodule_is_deprecated_use_compiledwasmmodule.patch
|
||||
|
@ -39,3 +38,4 @@ fix_remove_implicit_type_conversions.patch
|
|||
fix_include_io_h_in_uvwasi_for_win.patch
|
||||
fix_--perf-prof_only_works_on_linux.patch
|
||||
fix_we_need_to_eager-load_cjs_modules.patch
|
||||
fix_don_t_preparemainexecution_twice.patch
|
||||
|
|
|
@ -916,10 +916,10 @@ index 0000000000000000000000000000000000000000..f13b471d17128468bed06e66bd03a2ea
|
|||
+}
|
||||
diff --git a/filenames.json b/filenames.json
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..147561938788aac7021fe340f64fd8b4303603e6
|
||||
index 0000000000000000000000000000000000000000..aa9aa6d32f7d33a6f82ccb32a52f53ed3d5a77f0
|
||||
--- /dev/null
|
||||
+++ b/filenames.json
|
||||
@@ -0,0 +1,461 @@
|
||||
@@ -0,0 +1,460 @@
|
||||
+// This file is automatically generated by generate_gn_filenames_json.py
|
||||
+// DO NOT EDIT
|
||||
+{
|
||||
|
@ -988,7 +988,6 @@ index 0000000000000000000000000000000000000000..147561938788aac7021fe340f64fd8b4
|
|||
+ }
|
||||
+ ],
|
||||
+ "library_files": [
|
||||
+ "lib/internal/bootstrap/environment.js",
|
||||
+ "lib/internal/bootstrap/loaders.js",
|
||||
+ "lib/internal/bootstrap/node.js",
|
||||
+ "lib/internal/bootstrap/pre_execution.js",
|
||||
|
@ -1587,7 +1586,7 @@ index 0000000000000000000000000000000000000000..f3c5c798c0aefcb8cf9b1570a7b4817c
|
|||
+ args = rebase_path(inputs + outputs, root_build_dir)
|
||||
+}
|
||||
diff --git a/src/node_version.h b/src/node_version.h
|
||||
index 489dff631e51d1e93ed79acc48e52d33cd9c66d1..3f7349a4fa77aaae258ed32f378384165260c5b0 100644
|
||||
index e5205bb303fab8e53b56db68543a47c47280e3d4..53b97162319a0cc300b2d8950ffb414db6bf52e8 100644
|
||||
--- a/src/node_version.h
|
||||
+++ b/src/node_version.h
|
||||
@@ -89,7 +89,10 @@
|
||||
|
|
|
@ -8,7 +8,7 @@ once we stop warning and begin to unilaterally prevent non-context aware modules
|
|||
from being loaded.
|
||||
|
||||
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
|
||||
index e7bd18855fb98a822833b4366bfb595dccfc1b6f..a96f891f675cc598e912a5e010c24938a9f6fc98 100644
|
||||
index c86b5851ca9332ca440443e5feab2e65c7ac30b9..9416cf377871c217413bd9bcc27a7b35c9de1ca2 100644
|
||||
--- a/lib/internal/bootstrap/pre_execution.js
|
||||
+++ b/lib/internal/bootstrap/pre_execution.js
|
||||
@@ -80,8 +80,10 @@ function patchProcessObject(expandArgv1) {
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@slack-corp.com>
|
||||
Date: Wed, 17 Jul 2019 14:45:59 -0700
|
||||
Subject: chore: split CreateEnvironment into CreateEnvironment and
|
||||
BootstrapEnvironment
|
||||
|
||||
This allows us to run operations on a created but not yet bootstrapped
|
||||
environment such as setting up an InspectorAgent
|
||||
|
||||
diff --git a/src/api/environment.cc b/src/api/environment.cc
|
||||
index 356131156b4a714eebf4e202cd105f0f184e3852..96192f0ea4174315d73e03849ce1bed996afc44c 100644
|
||||
--- a/src/api/environment.cc
|
||||
+++ b/src/api/environment.cc
|
||||
@@ -263,7 +263,8 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
||||
int argc,
|
||||
const char* const* argv,
|
||||
int exec_argc,
|
||||
- const char* const* exec_argv) {
|
||||
+ const char* const* exec_argv,
|
||||
+ bool bootstrap) {
|
||||
Isolate* isolate = context->GetIsolate();
|
||||
HandleScope handle_scope(isolate);
|
||||
Context::Scope context_scope(context);
|
||||
@@ -281,9 +282,16 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
||||
Environment::kOwnsProcessState |
|
||||
Environment::kOwnsInspector));
|
||||
env->InitializeLibuv(per_process::v8_is_profiling);
|
||||
- if (env->RunBootstrapping().IsEmpty()) {
|
||||
+ if (bootstrap && !BootstrapEnvironment(env)) {
|
||||
return nullptr;
|
||||
}
|
||||
+ return env;
|
||||
+}
|
||||
+
|
||||
+bool BootstrapEnvironment(Environment* env) {
|
||||
+ if (env->RunBootstrapping().IsEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
std::vector<Local<String>> parameters = {
|
||||
env->require_string(),
|
||||
@@ -296,9 +304,10 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
||||
if (ExecuteBootstrapper(
|
||||
env, "internal/bootstrap/environment", ¶meters, &arguments)
|
||||
.IsEmpty()) {
|
||||
- return nullptr;
|
||||
+ return false;
|
||||
}
|
||||
- return env;
|
||||
+
|
||||
+ return true;
|
||||
}
|
||||
|
||||
void FreeEnvironment(Environment* env) {
|
||||
diff --git a/src/node.h b/src/node.h
|
||||
index e3258434eba34124c71562225e295cd1807fdf7c..2ac35208ae8b2cfd067b5b712d4447121ef6e47d 100644
|
||||
--- a/src/node.h
|
||||
+++ b/src/node.h
|
||||
@@ -326,7 +326,9 @@ NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
|
||||
int argc,
|
||||
const char* const* argv,
|
||||
int exec_argc,
|
||||
- const char* const* exec_argv);
|
||||
+ const char* const* exec_argv,
|
||||
+ bool bootstrap = true);
|
||||
+NODE_EXTERN bool BootstrapEnvironment(Environment* env);
|
||||
|
||||
NODE_EXTERN void LoadEnvironment(Environment* env);
|
||||
NODE_EXTERN void FreeEnvironment(Environment* env);
|
58
patches/node/fix_don_t_preparemainexecution_twice.patch
Normal file
58
patches/node/fix_don_t_preparemainexecution_twice.patch
Normal file
|
@ -0,0 +1,58 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shelley Vohr <shelley.vohr@gmail.com>
|
||||
Date: Fri, 21 Feb 2020 17:21:11 -0800
|
||||
Subject: fix: don't prepareMainExecution twice
|
||||
|
||||
In https://github.com/nodejs/node/pull/26788 (v12.0.0), Node.js added a
|
||||
bootstrapper to `CreateEnvironment`, which would prepare the main thread
|
||||
for execution any time an embedder created a new environment. However, this
|
||||
caused an unfortunate doubling-up effect; Node.js also ran bootstrapping
|
||||
(called `prepareMainThreadExecution`) for all other execution paths
|
||||
(like the repl, the actual main module, eval, etc).
|
||||
|
||||
To fix this, we can just remove bootstrapping code from `CreateEnvironment`.
|
||||
|
||||
diff --git a/lib/internal/bootstrap/environment.js b/lib/internal/bootstrap/environment.js
|
||||
deleted file mode 100644
|
||||
index 79a67dae378202ee377f2f138560b74f673af6e4..0000000000000000000000000000000000000000
|
||||
--- a/lib/internal/bootstrap/environment.js
|
||||
+++ /dev/null
|
||||
@@ -1,13 +0,0 @@
|
||||
-'use strict';
|
||||
-
|
||||
-// This runs necessary preparations to prepare a complete Node.js context
|
||||
-// that depends on run time states.
|
||||
-// It is currently only intended for preparing contexts for embedders.
|
||||
-
|
||||
-/* global markBootstrapComplete */
|
||||
-const {
|
||||
- prepareMainThreadExecution
|
||||
-} = require('internal/bootstrap/pre_execution');
|
||||
-
|
||||
-prepareMainThreadExecution();
|
||||
-markBootstrapComplete();
|
||||
diff --git a/src/api/environment.cc b/src/api/environment.cc
|
||||
index 356131156b4a714eebf4e202cd105f0f184e3852..6c2e0555f2ee554c8ac29465af01e9c47e1d81f9 100644
|
||||
--- a/src/api/environment.cc
|
||||
+++ b/src/api/environment.cc
|
||||
@@ -284,20 +284,6 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
|
||||
if (env->RunBootstrapping().IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
-
|
||||
- std::vector<Local<String>> parameters = {
|
||||
- env->require_string(),
|
||||
- FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")};
|
||||
- std::vector<Local<Value>> arguments = {
|
||||
- env->native_module_require(),
|
||||
- env->NewFunctionTemplate(MarkBootstrapComplete)
|
||||
- ->GetFunction(env->context())
|
||||
- .ToLocalChecked()};
|
||||
- if (ExecuteBootstrapper(
|
||||
- env, "internal/bootstrap/environment", ¶meters, &arguments)
|
||||
- .IsEmpty()) {
|
||||
- return nullptr;
|
||||
- }
|
||||
return env;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ Subject: fix: key gen APIs are not available in BoringSSL
|
|||
This will make Node's key pair generation APIs fail.
|
||||
|
||||
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
|
||||
index ad06141752eae90a655d710932b479f9cd8482ff..861d321d6170b25e874080d4c70dda201cab3248 100644
|
||||
index ac2d969f60cf95e0ad4972d67d83642d7161a579..114b4d503f3c1c01aa9999cf60a044d80a39acc1 100644
|
||||
--- a/src/node_crypto.cc
|
||||
+++ b/src/node_crypto.cc
|
||||
@@ -290,24 +290,14 @@ Maybe<bool> Decorate(Environment* env, Local<Object> obj,
|
||||
|
@ -34,7 +34,7 @@ index ad06141752eae90a655d710932b479f9cd8482ff..861d321d6170b25e874080d4c70dda20
|
|||
V(USER) \
|
||||
|
||||
#define V(name) case ERR_LIB_##name: lib = #name "_"; break;
|
||||
@@ -2557,8 +2547,11 @@ void SSLWrap<Base>::GetEphemeralKeyInfo(
|
||||
@@ -2560,8 +2550,11 @@ void SSLWrap<Base>::GetEphemeralKeyInfo(
|
||||
.Check();
|
||||
break;
|
||||
case EVP_PKEY_EC:
|
||||
|
@ -46,7 +46,7 @@ index ad06141752eae90a655d710932b479f9cd8482ff..861d321d6170b25e874080d4c70dda20
|
|||
{
|
||||
const char* curve_name;
|
||||
if (kid == EVP_PKEY_EC) {
|
||||
@@ -3894,12 +3887,15 @@ Local<Value> KeyObject::GetAsymmetricKeyType() const {
|
||||
@@ -3897,12 +3890,15 @@ Local<Value> KeyObject::GetAsymmetricKeyType() const {
|
||||
return env()->crypto_ec_string();
|
||||
case EVP_PKEY_ED25519:
|
||||
return env()->crypto_ed25519_string();
|
||||
|
@ -62,7 +62,7 @@ index ad06141752eae90a655d710932b479f9cd8482ff..861d321d6170b25e874080d4c70dda20
|
|||
default:
|
||||
return Undefined(env()->isolate());
|
||||
}
|
||||
@@ -6402,6 +6398,8 @@ class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
|
||||
@@ -6405,6 +6401,8 @@ class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
|
||||
if (EVP_PKEY_paramgen_init(param_ctx.get()) <= 0)
|
||||
return nullptr;
|
||||
|
||||
|
@ -71,7 +71,7 @@ index ad06141752eae90a655d710932b479f9cd8482ff..861d321d6170b25e874080d4c70dda20
|
|||
if (EVP_PKEY_CTX_set_dsa_paramgen_bits(param_ctx.get(), modulus_bits_) <= 0)
|
||||
return nullptr;
|
||||
|
||||
@@ -6421,6 +6419,8 @@ class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
|
||||
@@ -6424,6 +6422,8 @@ class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
|
||||
|
||||
EVPKeyCtxPointer key_ctx(EVP_PKEY_CTX_new(params.get(), nullptr));
|
||||
return key_ctx;
|
||||
|
@ -80,7 +80,7 @@ index ad06141752eae90a655d710932b479f9cd8482ff..861d321d6170b25e874080d4c70dda20
|
|||
}
|
||||
|
||||
private:
|
||||
@@ -7101,9 +7101,12 @@ void Initialize(Local<Object> target,
|
||||
@@ -7104,9 +7104,12 @@ void Initialize(Local<Object> target,
|
||||
env->SetMethod(target, "generateKeyPairEC", GenerateKeyPairEC);
|
||||
env->SetMethod(target, "generateKeyPairNid", GenerateKeyPairNid);
|
||||
NODE_DEFINE_CONSTANT(target, EVP_PKEY_ED25519);
|
||||
|
|
|
@ -8,7 +8,7 @@ The BoringSSL incompatibilities (OPENSSL_memdup) will be shimmed in and this sho
|
|||
be removed when the associated update is rolled into Chromium.
|
||||
|
||||
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
|
||||
index 7950c68f52050b7c9a6798b653a9c831256b21b5..41b72d010824234c567586524d22cae6ac849edb 100644
|
||||
index 114b4d503f3c1c01aa9999cf60a044d80a39acc1..de6828fc44752789bef02d29d3320dbb6f41448a 100644
|
||||
--- a/src/node_crypto.cc
|
||||
+++ b/src/node_crypto.cc
|
||||
@@ -5514,18 +5514,6 @@ bool PublicKeyCipher::Cipher(Environment* env,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue