Skip to content

Commit

Permalink
buffer: always allocate typed arrays outside heap
Browse files Browse the repository at this point in the history
By default v8 allocates typed arrays <= 64 bytes inside the v8 heap. In
these cases the memory pointer returned by Buffer::Data() can change
while the memory is being operated on. Resolve by passing a flag that
forces all typed arrays outside the v8 heap.

Fixes: 74178a5 "buffer: construct Uint8Array in JS"
PR-URL: #2893
Reviewed-By: Fedor Indutny <[email protected]>
  • Loading branch information
trevnorris authored and Fishrock123 committed Sep 16, 2015
1 parent 7df018a commit 4b4cfa2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3685,6 +3685,12 @@ void Init(int* argc,
V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1);
}

// Unconditionally force typed arrays to allocate outside the v8 heap. This
// is to prevent memory pointers from being moved around that are returned by
// Buffer::Data().
const char no_typed_array_heap[] = "--typed_array_max_size_in_heap=0";
V8::SetFlagsFromString(no_typed_array_heap, sizeof(no_typed_array_heap) - 1);

if (!use_debug_agent) {
RegisterDebugSignalHandler();
}
Expand Down

0 comments on commit 4b4cfa2

Please sign in to comment.