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

(v7.x backport) src: make AtExit callback's per Environment #12664

Closed

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Apr 26, 2017

This pull request contains two commits as the latter depends on the former.
I can make these separate if needed.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • [z] commit message follows commit guidelines
Affected core subsystem(s)

src

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. tools Issues and PRs related to the tools directory. v7.x labels Apr 26, 2017
@addaleax
Copy link
Member

@danbev Do you want to wait for a resolution on #12621 (comment)?

@danbev
Copy link
Contributor Author

danbev commented Apr 27, 2017

@danbev Do you want to wait for a resolution on #12621 (comment)?

Yes, that makes sense. For some reason I did not notice that issue before. Thanks

@addaleax
Copy link
Member

addaleax commented May 1, 2017

@danbev Do you want to cherry-pick d5db4d2 in here?

@danbev
Copy link
Contributor Author

danbev commented May 1, 2017

@danbev Do you want to cherry-pick d5db4d2 in here?

Absolutely, I'll do that first thing tomorrow.

This commit tries to make it simpler to add unit tests (cctest) for
code that needs to test node core funtionality but that might not be
appropriate as an addon or a JavaScript test. An example of this could
be adding functionality targeted for situations when Node itself is
embedded.

Currently it was not as easy, or efficient, as one would have hoped to
add such tests. The object output directories vary for different
operating systems which we need to link to so that we don't have an
additional compilation step.

PR-URL: nodejs#11956
Ref: nodejs#9163
Reviewed-By: James M Snell <jasnell@gmail.com>
@danbev danbev force-pushed the v7.x-at-exit-per-environment branch from 79f550f to ed545be Compare May 2, 2017 05:23
bnoordhuis and others added 3 commits May 2, 2017 07:23
It makes timers and other libuv handles fire intermittently after the
'exit' event, contrary to what the documentation states.

Regression introduced in commit aac79df ("src: use stack-allocated
Environment instances") from June last year that made the
`while (handle_cleanup_waiting_ != 0) uv_run(event_loop(), UV_RUN_ONCE)`
loop run unconditionally on exit because it merged CleanupHandles() into
the Environment destructor.

This change breaks parallel/test-async-wrap-throw-from-callback because
the async_wrap idle handle is no longer cleaned up, which I resolved
pragmatically by removing the test.

In all seriousness, it is being removed in the upcoming async_wrap
revamp - it doesn't make sense to sink a lot of time in it now.

Fixes: nodejs#12322
PR-URL: nodejs#12344
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit attempts to address one of the TODOs in
nodejs#4641 regarding making the
AtExit callback's per environment, instead of the current global.

bnoordhuis provided a few options for solving this, and one was to
use a thread-local which is what this commit attempts to do.

PR-URL: nodejs#9163
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
The test fixtures create multiple node::Environments that all use the
uv_default_loop(), and since the test does not clean up the handles
created by Environment::Start(), the default libuv loop structure
contains dangling pointers after the first Environment is freed,
which then means that creating new handles leads to memory corruption.

PR-URL: nodejs#12621
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@danbev
Copy link
Contributor Author

danbev commented May 2, 2017

@gibfahn
Copy link
Member

gibfahn commented Jun 18, 2017

I don't think this is going to land 😢 , closing.

@gibfahn gibfahn closed this Jun 18, 2017
@danbev danbev deleted the v7.x-at-exit-per-environment branch February 28, 2018 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants