Skip to content

Commit

Permalink
src: set arraybuffer_untransferable_private_symbol
Browse files Browse the repository at this point in the history
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: #31052
  • Loading branch information
thangktran committed Dec 23, 2019
1 parent 118b28a commit 0d11d4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,10 @@ void Initialize(Local<Object> 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"),
Expand Down
3 changes: 3 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint8Array> uint8_arr =
Uint8Array::New(ab, 0, kSessionUint8FieldCount);
Expand Down

0 comments on commit 0d11d4c

Please sign in to comment.