Skip to content

Commit 4b4cfa2

Browse files
trevnorrisFishrock123
authored andcommitted
buffer: always allocate typed arrays outside heap
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]>
1 parent 7df018a commit 4b4cfa2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/node.cc

+6
Original file line numberDiff line numberDiff line change
@@ -3685,6 +3685,12 @@ void Init(int* argc,
36853685
V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1);
36863686
}
36873687

3688+
// Unconditionally force typed arrays to allocate outside the v8 heap. This
3689+
// is to prevent memory pointers from being moved around that are returned by
3690+
// Buffer::Data().
3691+
const char no_typed_array_heap[] = "--typed_array_max_size_in_heap=0";
3692+
V8::SetFlagsFromString(no_typed_array_heap, sizeof(no_typed_array_heap) - 1);
3693+
36883694
if (!use_debug_agent) {
36893695
RegisterDebugSignalHandler();
36903696
}

0 commit comments

Comments
 (0)