Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v10.x] domain: avoid circular memory references #27749

Closed
wants to merge 2 commits into from

Conversation

MylesBorins
Copy link
Contributor

@MylesBorins MylesBorins commented May 17, 2019

Backport of #25993

Add a simple `WeakReference` utility that we can use until the
language provides something on its own.

PR-URL: nodejs#25993
Fixes: nodejs#23862
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Avoid circular references that the JS engine cannot see through
because it involves an `async id` ⇒ `domain` link.

Using weak references is not a great solution, because it increases
the domain module’s dependency on internals and the added calls into
C++ may affect performance, but it seems like the least bad one.

PR-URL: nodejs#25993
Fixes: nodejs#23862
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. domain Issues and PRs related to the domain subsystem. util Issues and PRs related to the built-in util module. v10.x labels May 17, 2019
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@MylesBorins
Copy link
Contributor Author

hmmm...

looks like we are getting a consistent failure on windows

assert.js:84
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual

- 'EAI_FAIL'
+ 'ENOTFOUND'
    at Socket.<anonymous> (c:\workspace\node-test-binary-windows\test\parallel\test-net-dns-error.js:37:10)
    at Socket.<anonymous> (c:\workspace\node-test-binary-windows\test\common\index.js:379:15)
    at Socket.emit (events.js:198:13)
    at GetAddrInfoReqWrap.emitLookup [as callback] (net.js:1004:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)

@nodejs-github-bot
Copy link
Collaborator

MylesBorins pushed a commit that referenced this pull request May 20, 2019
Add a simple `WeakReference` utility that we can use until the
language provides something on its own.

Backport-PR-URL: #27749
PR-URL: #25993
Fixes: #23862
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 20, 2019
Avoid circular references that the JS engine cannot see through
because it involves an `async id` ⇒ `domain` link.

Using weak references is not a great solution, because it increases
the domain module’s dependency on internals and the added calls into
C++ may affect performance, but it seems like the least bad one.

Backport-PR-URL: #27749
PR-URL: #25993
Fixes: #23862
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@MylesBorins
Copy link
Contributor Author

landed in 25d73aa...ec02117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. domain Issues and PRs related to the domain subsystem. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants