From 90f7a5c010f7f22eb73807f6401e3924fa36c700 Mon Sep 17 00:00:00 2001 From: Thang Tran Date: Sat, 21 Dec 2019 09:09:15 +0100 Subject: [PATCH] src: set arraybuffer_untransferable_private_symbol for `ArrayBuffer` whose buffers are not own by `BackingStore`. This would help us avoid problem with the new V8 BackingStore API where new `ArrayBuffer` is allocated at the same place of previous `ArrayBuffer` that is still being tracked in `BackingStore` table. PR-URL: https://github.com/nodejs/node/pull/31053 Refs: https://github.com/nodejs/node/issues/31052 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- src/node_buffer.cc | 4 ++++ src/node_http2.cc | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index c04be68d1b0cbe..f091ac96209721 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -1213,6 +1213,10 @@ void Initialize(Local target, // TODO(thangktran): drop this check when V8 is pumped to 8.0 . if (!array_buffer->IsExternal()) array_buffer->Externalize(array_buffer->GetBackingStore()); + array_buffer->SetPrivate( + env->context(), + env->arraybuffer_untransferable_private_symbol(), + True(env->isolate())).Check(); CHECK(target ->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "zeroFill"), diff --git a/src/node_http2.cc b/src/node_http2.cc index 1110288f6f9a9d..a4d1df0ca9fdfb 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -578,6 +578,9 @@ Http2Session::Http2Session(Environment* env, // TODO(thangktran): drop this check when V8 is pumped to 8.0 . if (!ab->IsExternal()) ab->Externalize(ab->GetBackingStore()); + ab->SetPrivate(env->context(), + env->arraybuffer_untransferable_private_symbol(), + True(env->isolate())).Check(); js_fields_ab_.Reset(env->isolate(), ab); Local uint8_arr = Uint8Array::New(ab, 0, kSessionUint8FieldCount);