From 068f0cce96975014cf0f78ad84f5218f24b3608b Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 2 Mar 2018 10:16:09 -0800 Subject: [PATCH 01/10] update node ref to electron-node-v9.7.0 --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index 3895d8f1ca3..86c3cc8a38a 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 3895d8f1ca32edce4c9e04b28948ddbd05c21269 +Subproject commit 86c3cc8a38a15a05a05c8a256eb72013cd240e78 From d88fa8b787d2adf13210ac2e0ec944d29a0ab485 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 2 Mar 2018 11:16:15 -0800 Subject: [PATCH 02/10] OPENSSL_PRODUCT => openssl_product --- common.gypi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index f4189345646..f423cc2a1ab 100644 --- a/common.gypi +++ b/common.gypi @@ -19,7 +19,7 @@ 'openssl_fips': '', 'openssl_no_asm': 1, 'use_openssl_def': 0, - 'OPENSSL_PRODUCT': 'libopenssl.a', + 'openssl_product': 'libopenssl.a', 'node_release_urlbase': 'https://atom.io/download/electron', 'node_byteorder': ' Date: Fri, 2 Mar 2018 11:51:19 -0800 Subject: [PATCH 03/10] node => node_lib and V8_BASE => v8_base --- common.gypi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common.gypi b/common.gypi index f423cc2a1ab..e47b3077694 100644 --- a/common.gypi +++ b/common.gypi @@ -44,7 +44,7 @@ 'uv_library': 'static_library', 'uv_parent_path': 'vendor/node/deps/uv', 'uv_use_dtrace': 'false', - 'V8_BASE': '', + 'v8_base': '', 'v8_postmortem_support': 'false', 'v8_enable_i18n_support': 'false', 'v8_enable_inspector': '1', @@ -52,7 +52,7 @@ # Settings to compile node under Windows. 'target_defaults': { 'target_conditions': [ - ['_target_name in ["libuv", "http_parser", "openssl", "openssl-cli", "cares", "node", "zlib", "nghttp2"]', { + ['_target_name in ["libuv", "http_parser", "openssl", "openssl-cli", "cares", "node_lib", "zlib", "nghttp2"]', { 'msvs_disabled_warnings': [ 4003, # not enough actual parameters for macro 'V' 4013, # 'free' undefined; assuming extern returning int @@ -136,7 +136,7 @@ }], ], }], - ['_target_name=="node"', { + ['_target_name=="node_lib"', { 'include_dirs': [ '<(libchromiumcontent_src_dir)', '<(libchromiumcontent_src_dir)/third_party/icu/source/common', @@ -245,7 +245,7 @@ }], # OS=="win" ], }], - ['OS=="linux" and _toolset=="target" and _target_name in ["dump_syms", "node"]', { + ['OS=="linux" and _toolset=="target" and _target_name in ["dump_syms", "node_lib"]', { 'conditions': [ ['libchromiumcontent_component==0', { 'libraries': [ From c8ef15cf4040989c170eb7280546080deae021d9 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 2 Mar 2018 15:58:51 -0800 Subject: [PATCH 04/10] update node::Environment::TickInfo calls --- atom/common/api/atom_bindings.cc | 6 +++--- vendor/node | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index a41f2eebddd..2411d5a1195 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -103,11 +103,11 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) { if (callback_scope.in_makecallback()) continue; node::Environment::TickInfo* tick_info = env->tick_info(); - if (tick_info->length() == 0) + if (!tick_info->has_scheduled()) env->isolate()->RunMicrotasks(); v8::Local process = env->process_object(); - if (tick_info->length() == 0) - tick_info->set_index(0); + if (!tick_info->has_scheduled()) + return; env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty(); } diff --git a/vendor/node b/vendor/node index 86c3cc8a38a..9c2b9b16af4 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 86c3cc8a38a15a05a05c8a256eb72013cd240e78 +Subproject commit 9c2b9b16af48f33d2fa73bab30206ba5b15d9dde From 3fea581ec80137bd6a0ffdbbfe0d705ec059f591 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sat, 3 Mar 2018 15:09:49 +0530 Subject: [PATCH 05/10] build node target for <(node_lib_target_name) --- electron.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron.gyp b/electron.gyp index e0391b0d8b6..6f8fbcd0562 100644 --- a/electron.gyp +++ b/electron.gyp @@ -245,7 +245,7 @@ 'atom_js2c', 'vendor/pdf_viewer/pdf_viewer.gyp:pdf_viewer', 'brightray/brightray.gyp:brightray', - 'vendor/node/node.gyp:node', + 'vendor/node/node.gyp:node_lib', ], 'defines': [ # We need to access internal implementations of Node. From 1882b88c78509c3e6d8ae1fdd657c064b3bcb6ac Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sat, 3 Mar 2018 21:20:11 -0800 Subject: [PATCH 06/10] clean node ref and remove short circuit --- atom/common/api/atom_bindings.cc | 2 -- vendor/node | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 2411d5a1195..967ee5a1ddd 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -106,8 +106,6 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) { if (!tick_info->has_scheduled()) env->isolate()->RunMicrotasks(); v8::Local process = env->process_object(); - if (!tick_info->has_scheduled()) - return; env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty(); } diff --git a/vendor/node b/vendor/node index 9c2b9b16af4..4728f9231aa 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 9c2b9b16af48f33d2fa73bab30206ba5b15d9dde +Subproject commit 4728f9231aac37cbfeed28b630d432686d6e16c4 From 50a5a69c46604401d10b97eecd16001c0b922329 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 8 Mar 2018 22:50:01 +0530 Subject: [PATCH 07/10] update node ref fixing crash with buffer allocation --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index 4728f9231aa..ac00467c8b6 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 4728f9231aac37cbfeed28b630d432686d6e16c4 +Subproject commit ac00467c8b6954cbb6b9b64c4643af522a1c207e From 5d2452608d02e261218ff914fba45cb912e85275 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Mar 2018 14:54:25 +0900 Subject: [PATCH 08/10] Use InternalCallbackScope for ticking event loop --- atom/common/api/atom_bindings.cc | 15 +++++---------- common.gypi | 2 ++ vendor/node | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 967ee5a1ddd..1a52a9d3ceb 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -97,16 +97,11 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) { for (std::list::const_iterator it = self->pending_next_ticks_.begin(); it != self->pending_next_ticks_.end(); ++it) { - node::Environment* env = *it; - // KickNextTick, copied from node.cc: - node::Environment::AsyncCallbackScope callback_scope(env); - if (callback_scope.in_makecallback()) - continue; - node::Environment::TickInfo* tick_info = env->tick_info(); - if (!tick_info->has_scheduled()) - env->isolate()->RunMicrotasks(); - v8::Local process = env->process_object(); - env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty(); + node::InternalCallbackScope scope( + *it, + v8::Local(), + {0, 0}, + node::InternalCallbackScope::kAllowEmptyResource); } self->pending_next_ticks_.clear(); diff --git a/common.gypi b/common.gypi index e47b3077694..056bd361659 100644 --- a/common.gypi +++ b/common.gypi @@ -61,6 +61,7 @@ 4055, # 'type cast' : from data pointer 'void *' to function pointer 4057, # 'function' : 'volatile LONG *' differs in indirection to slightly different base types from 'unsigned long *' 4065, # switch statement contains 'default' but no 'case' labels + 4129, # unrecognized character escape sequence 4189, # 4131, # uses old-style declarator 4133, # incompatible types @@ -74,6 +75,7 @@ 4232, # address of dllimport 'free' is not static, identity not guaranteed 4291, # no matching operator delete found 4295, # array is too small to include a terminating null character + 4309, # 'static_cast': truncation of constant value 4311, # 'type cast': pointer truncation from 'void *const ' to 'unsigned long' 4389, # '==' : signed/unsigned mismatch 4456, # declaration of 'm' hides previous local declaration diff --git a/vendor/node b/vendor/node index ac00467c8b6..668f3cd06e0 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit ac00467c8b6954cbb6b9b64c4643af522a1c207e +Subproject commit 668f3cd06e0b9c24a1aa2d913f22626fff7decd2 From 83f01096c017de42a3b7c9c6de6f4bd3f530d81a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Mar 2018 16:13:51 +0900 Subject: [PATCH 09/10] When a render process is crashed, it might be reused --- atom/browser/atom_browser_client.cc | 9 +++++++++ atom/browser/atom_browser_client.h | 1 + 2 files changed, 10 insertions(+) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 69fd274f6e8..42892025b04 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -140,6 +140,11 @@ void AtomBrowserClient::RemoveProcessPreferences(int process_id) { process_preferences_.erase(process_id); } +bool AtomBrowserClient::IsProcessObserved(int process_id) { + base::AutoLock auto_lock(process_preferences_lock_); + return process_preferences_.find(process_id) != process_preferences_.end(); +} + bool AtomBrowserClient::IsRendererSandboxed(int process_id) { base::AutoLock auto_lock(process_preferences_lock_); auto it = process_preferences_.find(process_id); @@ -160,7 +165,11 @@ bool AtomBrowserClient::RendererDisablesPopups(int process_id) { void AtomBrowserClient::RenderProcessWillLaunch( content::RenderProcessHost* host) { + // When a render process is crashed, it might be reused. int process_id = host->GetID(); + if (IsProcessObserved(process_id)) + return; + host->AddFilter(new printing::PrintingMessageFilter(process_id)); host->AddFilter(new TtsMessageFilter(process_id, host->GetBrowserContext())); host->AddFilter( diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 54ade8170a7..14633370ff0 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -126,6 +126,7 @@ class AtomBrowserClient : public brightray::BrowserClient, }; void AddProcessPreferences(int process_id, ProcessPreferences prefs); void RemoveProcessPreferences(int process_id); + bool IsProcessObserved(int process_id); bool IsRendererSandboxed(int process_id); bool RendererUsesNativeWindowOpen(int process_id); bool RendererDisablesPopups(int process_id); From e79b18762e35459dba146770ca6b92b3ea163b9c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Mar 2018 16:14:24 +0900 Subject: [PATCH 10/10] Enter context scope before InternalCallbackScope --- atom/common/api/atom_bindings.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 1a52a9d3ceb..bc8bc4675d0 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -8,6 +8,7 @@ #include #include +#include "atom/common/api/locker.h" #include "atom/common/atom_version.h" #include "atom/common/chrome_version.h" #include "atom/common/native_mate_converters/string16_converter.h" @@ -97,8 +98,11 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) { for (std::list::const_iterator it = self->pending_next_ticks_.begin(); it != self->pending_next_ticks_.end(); ++it) { + node::Environment* env = *it; + mate::Locker locker(env->isolate()); + v8::Context::Scope context_scope(env->context()); node::InternalCallbackScope scope( - *it, + env, v8::Local(), {0, 0}, node::InternalCallbackScope::kAllowEmptyResource);