From 0d11d4c879dee484a55c9e8d7281bfc722295a4c 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. Ref: https://github.com/nodejs/node/issues/31052 --- 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 db3bd035b34444..84a966e2fec9e3 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);