<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/node-new.git/src/node_contextify.h, branch devsnek-patch-1</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>src: add check against non-weak BaseObjects at process exit</title>
<updated>2020-10-07T08:54:34+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-10-03T20:45:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=40364b181d44ba90b6ce7cda4f9e3297581121c5'/>
<id>40364b181d44ba90b6ce7cda4f9e3297581121c5</id>
<content type='text'>
When a process exits cleanly, i.e. because the event loop ends up
without things to wait for, the Node.js objects that are left on
the heap should be:

 1. weak, i.e. ready for garbage collection once no longer
    referenced, or
 2. detached, i.e. scheduled for destruction once no longer
    referenced, or
 3. an unrefed libuv handle, i.e. does not keep the event loop
    alive, or
 4. an inactive libuv handle (essentially the same here)

There are a few exceptions to this rule, but generally,
if there are C++-backed Node.js objects on the heap
that do not fall into the above categories, we may be looking
at a potential memory leak. Most likely, the cause is a missing
`MakeWeak()` call on the corresponding object.

In order to avoid this kind of problem, we check the list
of BaseObjects for these criteria. In this commit, we only do so
when explicitly instructed to or when in debug mode
(where --verify-base-objects is always-on).

In particular, this avoids the kinds of memory leak issues
that were fixed in the PRs referenced below.

Refs: https://github.com/nodejs/node/pull/35488
Refs: https://github.com/nodejs/node/pull/35487
Refs: https://github.com/nodejs/node/pull/35481

PR-URL: https://github.com/nodejs/node/pull/35490
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Benjamin Gruenbaum &lt;benjamingr@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When a process exits cleanly, i.e. because the event loop ends up
without things to wait for, the Node.js objects that are left on
the heap should be:

 1. weak, i.e. ready for garbage collection once no longer
    referenced, or
 2. detached, i.e. scheduled for destruction once no longer
    referenced, or
 3. an unrefed libuv handle, i.e. does not keep the event loop
    alive, or
 4. an inactive libuv handle (essentially the same here)

There are a few exceptions to this rule, but generally,
if there are C++-backed Node.js objects on the heap
that do not fall into the above categories, we may be looking
at a potential memory leak. Most likely, the cause is a missing
`MakeWeak()` call on the corresponding object.

In order to avoid this kind of problem, we check the list
of BaseObjects for these criteria. In this commit, we only do so
when explicitly instructed to or when in debug mode
(where --verify-base-objects is always-on).

In particular, this avoids the kinds of memory leak issues
that were fixed in the PRs referenced below.

Refs: https://github.com/nodejs/node/pull/35488
Refs: https://github.com/nodejs/node/pull/35487
Refs: https://github.com/nodejs/node/pull/35481

PR-URL: https://github.com/nodejs/node/pull/35490
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Benjamin Gruenbaum &lt;benjamingr@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>vm: add run-after-evaluate microtask mode</title>
<updated>2020-06-26T18:41:33+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-06-22T22:33:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=f63436d190b60e12131036aa9d1888d9023e9127'/>
<id>f63436d190b60e12131036aa9d1888d9023e9127</id>
<content type='text'>
This allows timeouts to apply to e.g. `Promise`s and `async function`s
from code running inside of `vm.Context`s, by giving the Context its
own microtasks queue.

Fixes: https://github.com/nodejs/node/issues/3020

PR-URL: https://github.com/nodejs/node/pull/34023
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Denys Otrishko &lt;shishugi@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This allows timeouts to apply to e.g. `Promise`s and `async function`s
from code running inside of `vm.Context`s, by giving the Context its
own microtasks queue.

Fixes: https://github.com/nodejs/node/issues/3020

PR-URL: https://github.com/nodejs/node/pull/34023
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Denys Otrishko &lt;shishugi@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: improve handling of internal field counting</title>
<updated>2020-03-02T18:58:36+00:00</updated>
<author>
<name>James M Snell</name>
<email>jasnell@gmail.com</email>
</author>
<published>2020-02-25T22:37:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=0fac393d263fc7e2f4f054c9d4aab0c1c3cf00c8'/>
<id>0fac393d263fc7e2f4f054c9d4aab0c1c3cf00c8</id>
<content type='text'>
Change suggested by bnoordhuis.

Improve handing of internal field counting by using enums.
Helps protect against future possible breakage if field
indexes are ever changed or added to.

Signed-off-by: James M Snell &lt;jasnell@gmail.com&gt;

PR-URL: https://github.com/nodejs/node/pull/31960
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Franziska Hinkelmann &lt;franziska.hinkelmann@gmail.com&gt;
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change suggested by bnoordhuis.

Improve handing of internal field counting by using enums.
Helps protect against future possible breakage if field
indexes are ever changed or added to.

Signed-off-by: James M Snell &lt;jasnell@gmail.com&gt;

PR-URL: https://github.com/nodejs/node/pull/31960
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Franziska Hinkelmann &lt;franziska.hinkelmann@gmail.com&gt;
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: make `CompiledFnEntry` a `BaseObject`</title>
<updated>2019-07-22T18:55:25+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2019-07-20T17:35:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=89e4b36e62978f54b2e33b4bce8197072dbe8af1'/>
<id>89e4b36e62978f54b2e33b4bce8197072dbe8af1</id>
<content type='text'>
In particular:

- Move the class definition to the relevant header file,
  i.e. `node_contextify.h`.
- Make sure that class instances are destroyed on
  `Environment` teardown.
- Make instances of the key object traceable in heap dumps. This is
  particularly relevant here because our C++ script → map key mapping
  could introduce memory leaks when the import function metadata refers
  back to the script in some way.

Refs: https://github.com/nodejs/node/pull/28671

PR-URL: https://github.com/nodejs/node/pull/28782
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In particular:

- Move the class definition to the relevant header file,
  i.e. `node_contextify.h`.
- Make sure that class instances are destroyed on
  `Environment` teardown.
- Make instances of the key object traceable in heap dumps. This is
  particularly relevant here because our C++ script → map key mapping
  could introduce memory leaks when the import function metadata refers
  back to the script in some way.

Refs: https://github.com/nodejs/node/pull/28671

PR-URL: https://github.com/nodejs/node/pull/28782
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Rich Trott &lt;rtrott@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>vm: fix gc bug with modules and compiled functions</title>
<updated>2019-07-19T21:45:46+00:00</updated>
<author>
<name>Gus Caplan</name>
<email>me@gus.host</email>
</author>
<published>2019-07-19T14:30:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=68c83f962e002a47f61648c5aa2adb41dbe6a358'/>
<id>68c83f962e002a47f61648c5aa2adb41dbe6a358</id>
<content type='text'>
PR-URL: https://github.com/nodejs/node/pull/28671
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Guy Bedford &lt;guybedford@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR-URL: https://github.com/nodejs/node/pull/28671
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Guy Bedford &lt;guybedford@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: add cleanup hook for ContextifyContext</title>
<updated>2019-07-14T21:23:33+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2019-07-10T22:12:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=00464b5282724a693582079244c09a1cba5d8e08'/>
<id>00464b5282724a693582079244c09a1cba5d8e08</id>
<content type='text'>
Otherwise there’s a memory leak left by the context when the Isolate
tears down without having run the weak callback.

PR-URL: https://github.com/nodejs/node/pull/28631
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Jeremiah Senkpiel &lt;fishrock123@rocketmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Otherwise there’s a memory leak left by the context when the Isolate
tears down without having run the weak callback.

PR-URL: https://github.com/nodejs/node/pull/28631
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Jeremiah Senkpiel &lt;fishrock123@rocketmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: prefer v8::Global over node::Persistent</title>
<updated>2019-04-29T22:23:33+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2019-04-17T21:16:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=723d5c058fa180684df13bd2a83bbf3ca6201957'/>
<id>723d5c058fa180684df13bd2a83bbf3ca6201957</id>
<content type='text'>
`v8::Global` is essentially a nicer variant of `node::Persistent` that,
in addition to reset-on-destroy, also implements move semantics.

This commit makes the necessary replacements, removes
`node::Persistent` and (now-)unnecessary inclusions of the
`node_persistent.h` header, and makes some of the functions that
take Persistents as arguments more generic so that they work with all
`v8::PersistentBase` flavours.

PR-URL: https://github.com/nodejs/node/pull/27287
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Eugene Ostroukhov &lt;eostroukhov@google.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`v8::Global` is essentially a nicer variant of `node::Persistent` that,
in addition to reset-on-destroy, also implements move semantics.

This commit makes the necessary replacements, removes
`node::Persistent` and (now-)unnecessary inclusions of the
`node_persistent.h` header, and makes some of the functions that
take Persistents as arguments more generic so that they work with all
`v8::PersistentBase` flavours.

PR-URL: https://github.com/nodejs/node/pull/27287
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Eugene Ostroukhov &lt;eostroukhov@google.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>module: revert module._compile to original state if module is patched</title>
<updated>2019-02-19T15:28:37+00:00</updated>
<author>
<name>Ujjwal Sharma</name>
<email>usharma1998@gmail.com</email>
</author>
<published>2018-11-07T16:47:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=5f8ccecaa2e44c4a04db95ccd278a7078c14dd77'/>
<id>5f8ccecaa2e44c4a04db95ccd278a7078c14dd77</id>
<content type='text'>
PR-URL: https://github.com/nodejs/node/pull/21573
Fixes: https://github.com/nodejs/node/issues/17396
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Ruben Bridgewater &lt;ruben@bridgewater.de&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR-URL: https://github.com/nodejs/node/pull/21573
Fixes: https://github.com/nodejs/node/issues/17396
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Ruben Bridgewater &lt;ruben@bridgewater.de&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: apply clang-tidy rule modernize-use-override</title>
<updated>2019-02-18T04:43:22+00:00</updated>
<author>
<name>gengjiawen</name>
<email>technicalcute@gmail.com</email>
</author>
<published>2019-02-14T15:12:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=c3d889182b0c958e922aec96e3aab43766884536'/>
<id>c3d889182b0c958e922aec96e3aab43766884536</id>
<content type='text'>
PR-URL: https://github.com/nodejs/node/pull/26103
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR-URL: https://github.com/nodejs/node/pull/26103
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>inspector,vm: remove --eval wrapper</title>
<updated>2019-02-03T19:40:16+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2019-01-30T22:13:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=cca897ef5d92b20c7862fab00116ea0727439c10'/>
<id>cca897ef5d92b20c7862fab00116ea0727439c10</id>
<content type='text'>
Report the actual source code when running with `--eval` and
`--inspect-brk`, by telling the vm module to break on the
first line of the script being executed rather than wrapping
the source code in a function.

PR-URL: https://github.com/nodejs/node/pull/25832
Reviewed-By: Eugene Ostroukhov &lt;eostroukhov@google.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Report the actual source code when running with `--eval` and
`--inspect-brk`, by telling the vm module to break on the
first line of the script being executed rather than wrapping
the source code in a function.

PR-URL: https://github.com/nodejs/node/pull/25832
Reviewed-By: Eugene Ostroukhov &lt;eostroukhov@google.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
