<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/node-new.git/src/node_buffer.cc, branch sam-github-tsc</title>
<subtitle>github.com: nodejs/node.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/'/>
<entry>
<title>worker: add public method for marking objects as untransferable</title>
<updated>2020-06-25T15:33:29+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-06-19T18:39:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=88fb5a5c7933022de750745e51e5dc0996a1e2c4'/>
<id>88fb5a5c7933022de750745e51e5dc0996a1e2c4</id>
<content type='text'>
We currently mark a number of `ArrayBuffer`s as not transferable,
including the `Buffer` pool and ones with finalizers provided
by C++ addons.

There is no good reason to assume that userland code might not
encounter similar problems, for example when doing `ArrayBuffer`
pooling similar to ours. Therefore, provide an API that lets
userland code also mark objects as not transferable.

PR-URL: https://github.com/nodejs/node/pull/33979
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We currently mark a number of `ArrayBuffer`s as not transferable,
including the `Buffer` pool and ones with finalizers provided
by C++ addons.

There is no good reason to assume that userland code might not
encounter similar problems, for example when doing `ArrayBuffer`
pooling similar to ours. Therefore, provide an API that lets
userland code also mark objects as not transferable.

PR-URL: https://github.com/nodejs/node/pull/33979
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: turn AllocatedBuffer into thin wrapper around v8::BackingStore</title>
<updated>2020-05-30T23:20:02+00:00</updated>
<author>
<name>James M Snell</name>
<email>jasnell@gmail.com</email>
</author>
<published>2020-05-14T19:03:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=e2cd71536161589dff96adf882970b9a33380f02'/>
<id>e2cd71536161589dff96adf882970b9a33380f02</id>
<content type='text'>
Alternative to https://github.com/nodejs/node/pull/33381 that
reimplements that change on top of moving AllocatedBuffer out
of env.h

PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Alternative to https://github.com/nodejs/node/pull/33381 that
reimplements that change on top of moving AllocatedBuffer out
of env.h

PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: extract AllocatedBuffer from env.h</title>
<updated>2020-05-30T23:20:00+00:00</updated>
<author>
<name>James M Snell</name>
<email>jasnell@gmail.com</email>
</author>
<published>2020-05-07T20:31:56+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=56ff1ee55a57b1169dc567f0f51e58a6f2ccda6d'/>
<id>56ff1ee55a57b1169dc567f0f51e58a6f2ccda6d</id>
<content type='text'>
Cleanup up env.h by removing things that are not
specific to `Environment`.

PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Cleanup up env.h by removing things that are not
specific to `Environment`.

PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>buffer,n-api: release external buffers from BackingStore callback</title>
<updated>2020-05-16T10:15:07+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-05-09T04:41:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=c1ee70ec168eedc3f9d193473d141b9c03e2df88'/>
<id>c1ee70ec168eedc3f9d193473d141b9c03e2df88</id>
<content type='text'>
Release `Buffer` and `ArrayBuffer` instances that were created through
our addon APIs and have finalizers attached to them only after V8 has
called the deleter callback passed to the `BackingStore`, instead of
relying on our own GC callback(s).

This fixes the following race condition:

1. Addon code allocates pointer P via `malloc`.
2. P is passed into `napi_create_external_buffer` with a finalization
   callback which calls `free(P)`. P is inserted into V8’s global array
   buffer table for tracking.
3. The finalization callback is executed on GC. P is freed and returned
   to the allocator. P is not yet removed from V8’s global array
   buffer table. (!)
4. Addon code attempts to allocate memory once again. The allocator
   returns P, as it is now available.
5. P is passed into `napi_create_external_buffer`. P still has not been
   removed from the v8 global array buffer table.
6. The world ends with `Check failed: result.second`.

Since our API contract is to call the finalizer on the JS thread on
which the `ArrayBuffer` was created, but V8 may call the `BackingStore`
deleter callback on another thread, fixing this requires posting
a task back to the JS thread.

Refs: https://github.com/nodejs/node/issues/32463#issuecomment-625877175
Fixes: https://github.com/nodejs/node/issues/32463

PR-URL: https://github.com/nodejs/node/pull/33321
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Release `Buffer` and `ArrayBuffer` instances that were created through
our addon APIs and have finalizers attached to them only after V8 has
called the deleter callback passed to the `BackingStore`, instead of
relying on our own GC callback(s).

This fixes the following race condition:

1. Addon code allocates pointer P via `malloc`.
2. P is passed into `napi_create_external_buffer` with a finalization
   callback which calls `free(P)`. P is inserted into V8’s global array
   buffer table for tracking.
3. The finalization callback is executed on GC. P is freed and returned
   to the allocator. P is not yet removed from V8’s global array
   buffer table. (!)
4. Addon code attempts to allocate memory once again. The allocator
   returns P, as it is now available.
5. P is passed into `napi_create_external_buffer`. P still has not been
   removed from the v8 global array buffer table.
6. The world ends with `Check failed: result.second`.

Since our API contract is to call the finalizer on the JS thread on
which the `ArrayBuffer` was created, but V8 may call the `BackingStore`
deleter callback on another thread, fixing this requires posting
a task back to the JS thread.

Refs: https://github.com/nodejs/node/issues/32463#issuecomment-625877175
Fixes: https://github.com/nodejs/node/issues/32463

PR-URL: https://github.com/nodejs/node/pull/33321
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>buffer,n-api: fix double ArrayBuffer::Detach() during cleanup</title>
<updated>2020-04-27T09:16:51+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-04-24T13:45:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=36993c05667bbfda66d84329278b82887771cc94'/>
<id>36993c05667bbfda66d84329278b82887771cc94</id>
<content type='text'>
These calls could fail if the `ArrayBuffer` had already been explicitly
detached at some point in the past.

The necessary test changes already came with 4f523c2c1a1c and could
be ported back to v12.x with a backport of this PR.

Fixes: https://github.com/nodejs/node/issues/33022
Refs: https://github.com/nodejs/node/pull/30551

PR-URL: https://github.com/nodejs/node/pull/33039
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Gerhard Stöbich &lt;deb2001-github@yahoo.de&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Juan José Arboleda &lt;soyjuanarbol@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These calls could fail if the `ArrayBuffer` had already been explicitly
detached at some point in the past.

The necessary test changes already came with 4f523c2c1a1c and could
be ported back to v12.x with a backport of this PR.

Fixes: https://github.com/nodejs/node/issues/33022
Refs: https://github.com/nodejs/node/pull/30551

PR-URL: https://github.com/nodejs/node/pull/33039
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Gerhard Stöbich &lt;deb2001-github@yahoo.de&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Juan José Arboleda &lt;soyjuanarbol@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: delete CallbackInfo when cleared from cleanup hook</title>
<updated>2020-03-23T18:02:04+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-03-21T09:08:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=678e1be6aa145b99397342bb4a00440ba4bf4999'/>
<id>678e1be6aa145b99397342bb4a00440ba4bf4999</id>
<content type='text'>
Fixes: https://github.com/nodejs/node/issues/32400

PR-URL: https://github.com/nodejs/node/pull/32405
Reviewed-By: Matheus Marchini &lt;mat@mmarchini.me&gt;
Reviewed-By: Jiawen Geng &lt;technicalcute@gmail.com&gt;
Reviewed-By: Michaël Zasso &lt;targos@protonmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes: https://github.com/nodejs/node/issues/32400

PR-URL: https://github.com/nodejs/node/pull/32405
Reviewed-By: Matheus Marchini &lt;mat@mmarchini.me&gt;
Reviewed-By: Jiawen Geng &lt;technicalcute@gmail.com&gt;
Reviewed-By: Michaël Zasso &lt;targos@protonmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: remove calls to deprecated ArrayBuffer methods</title>
<updated>2020-03-21T11:00:57+00:00</updated>
<author>
<name>Michaël Zasso</name>
<email>targos@protonmail.com</email>
</author>
<published>2020-03-19T10:28:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=d23eed256b2ba2c594011f6957fbabe2568c8751'/>
<id>d23eed256b2ba2c594011f6957fbabe2568c8751</id>
<content type='text'>
v8::ArrayBuffer::IsExternal and v8::ArrayBuffer::Externalize are
no longer necessary.

PR-URL: https://github.com/nodejs/node/pull/32358
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Matheus Marchini &lt;mat@mmarchini.me&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Jiawen Geng &lt;technicalcute@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
v8::ArrayBuffer::IsExternal and v8::ArrayBuffer::Externalize are
no longer necessary.

PR-URL: https://github.com/nodejs/node/pull/32358
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Matheus Marchini &lt;mat@mmarchini.me&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Jiawen Geng &lt;technicalcute@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: change Fill() to use ParseArrayIndex()</title>
<updated>2020-02-03T20:00:41+00:00</updated>
<author>
<name>ConorDavenport</name>
<email>cnrdavenport@gmail.com</email>
</author>
<published>2020-01-30T12:12:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=d4660aba6324096198bc17772ba16fce6259967d'/>
<id>d4660aba6324096198bc17772ba16fce6259967d</id>
<content type='text'>
Changed Fill() to use ParseArrayIndex() when getting start and end
of buffers instead of Uint32Value, supporting buffers of greater
than 2**32

Fixes: https://github.com/nodejs/node/issues/31514
Co-Authored-By: Rich Trott &lt;rtrott@gmail.com&gt;

PR-URL: https://github.com/nodejs/node/pull/31591
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Changed Fill() to use ParseArrayIndex() when getting start and end
of buffers instead of Uint32Value, supporting buffers of greater
than 2**32

Fixes: https://github.com/nodejs/node/issues/31514
Co-Authored-By: Rich Trott &lt;rtrott@gmail.com&gt;

PR-URL: https://github.com/nodejs/node/pull/31591
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lib,src: switch Buffer::kMaxLength to size_t</title>
<updated>2020-01-21T21:55:40+00:00</updated>
<author>
<name>Ben Noordhuis</name>
<email>info@bnoordhuis.nl</email>
</author>
<published>2020-01-18T09:55:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=5005c3c72c232915935b97800781467767964660'/>
<id>5005c3c72c232915935b97800781467767964660</id>
<content type='text'>
Change the type of `Buffer::kMaxLength` to size_t because upcoming
changes in V8 will allow typed arrays &gt; 2 GB on 64 bits platforms.

Not all platforms handle file reads and writes &gt; 2 GB though so keep
enforcing the 2 GB typed array limit for I/O operations.

Fixes: https://github.com/nodejs/node/issues/31399
Refs: https://github.com/libuv/libuv/pull/1501

PR-URL: https://github.com/nodejs/node/pull/31406
Reviewed-By: Richard Lau &lt;riclau@uk.ibm.com&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
Reviewed-By: Tobias Nießen &lt;tniessen@tnie.de&gt;
Reviewed-By: Shelley Vohr &lt;codebytere@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change the type of `Buffer::kMaxLength` to size_t because upcoming
changes in V8 will allow typed arrays &gt; 2 GB on 64 bits platforms.

Not all platforms handle file reads and writes &gt; 2 GB though so keep
enforcing the 2 GB typed array limit for I/O operations.

Fixes: https://github.com/nodejs/node/issues/31399
Refs: https://github.com/libuv/libuv/pull/1501

PR-URL: https://github.com/nodejs/node/pull/31406
Reviewed-By: Richard Lau &lt;riclau@uk.ibm.com&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
Reviewed-By: Tobias Nießen &lt;tniessen@tnie.de&gt;
Reviewed-By: Shelley Vohr &lt;codebytere@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: set arraybuffer_untransferable_private_symbol</title>
<updated>2019-12-25T11:01:56+00:00</updated>
<author>
<name>Thang Tran</name>
<email>trankimthang279@gmail.com</email>
</author>
<published>2019-12-21T08:09:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=90f7a5c010f7f22eb73807f6401e3924fa36c700'/>
<id>90f7a5c010f7f22eb73807f6401e3924fa36c700</id>
<content type='text'>
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 &lt;anna@addaleax.net&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;anna@addaleax.net&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
