| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
There was a problem hiding this comment.
I'd leave out the = nullptr, it looks unidiomatic. It should be static though, yes.
Sorry, something went wrong.
There was a problem hiding this comment.
@addaleax @bnoordhuis I'd like to make sure I understand the reason for making this static. My understanding is that a thread_local object is allocated when the thread begins and deallocated when the thread ends, so static in this case does not refer to storage but to linkage. And without the explicitstatic, the linkage would be external by default. Does that sound correct?
Sorry, something went wrong.
There was a problem hiding this comment.
Correct. static in this context is about linkage, not lifetime. Without static, the variable is visible to other compilation units.
Sorry, something went wrong.
There was a problem hiding this comment.
@bnoordhuis Thanks for clarifying that, I appreciate it.
Sorry, something went wrong.
There was a problem hiding this comment.
Just a suggestion, but you could make AtExitCallback a forward declaration in the node namespace here and only define it right before AtExit/RunAtExit. That would make sense insofar as the exact layout isn’t part of the API here, and having the definition of the struct close to its actual usage might be a tad more readable.
Sorry, something went wrong.
There was a problem hiding this comment.
That sounds good, I'll change that.
Sorry, something went wrong.
There was a problem hiding this comment.
CHECK_NE(env, nullptr);?
Sorry, something went wrong.
There was a problem hiding this comment.
A CHECK won't hurt but OTOH, if it's a nullptr, the caller is going to find out soon enough. :-)
Sorry, something went wrong.
There was a problem hiding this comment.
RunAtExit was a confusing name when I first read it… I don’t have anything better in mind rn, but if you do, feel free to add that here.
Sorry, something went wrong.
There was a problem hiding this comment.
How about RunAtExitCallbacks?
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, one more thing: env.h is not a public header, so if anyone actually wants to use RunAtExit in an addon, deprecating this puts them in quite the difficult position. ;)
Sorry, something went wrong.
There was a problem hiding this comment.
Oh that does not sound good, I'll revert that :)
Sorry, something went wrong.
|
OS X CI failure: error: thread-local storage is not supported for the current target 😞 (output) Maybe @bnoordhuis has a bit more context about who actually uses multiple Environments and in what way, I’ve always been wondering about that a bit. |
Sorry, something went wrong.
There was a problem hiding this comment.
These don't really need to be inlined. I'd move it to src/env.cc.
Sorry, something went wrong.
There was a problem hiding this comment.
Great, I'll move them.
Sorry, something went wrong.
There was a problem hiding this comment.
A CHECK won't hurt but OTOH, if it's a nullptr, the caller is going to find out soon enough. :-)
Sorry, something went wrong.
There was a problem hiding this comment.
I'd leave out the = nullptr, it looks unidiomatic. It should be static though, yes.
Sorry, something went wrong.
Yeah, I was kind of expecting that. If we had still supported VS 2013, that would have been a problem, too. @danbev You can use uv_key_t instead.
Embedders like electron and plask do. Electron for example has (or had) a context per tab. |
Sorry, something went wrong.
|
Forgot to mention, the OS X issue could be fixed by linking to libc++ instead of libstdc++ but that has some wider ranging implications and would make the pull request unsuitable for back-porting to v4.x and v6.x. EDIT: Scratch that, we already seem to be doing that in master? I see a -stdlib=libc++ in the arguments. |
Sorry, something went wrong.
I was not aware of uv_key_t, I'll take a look and try that out. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Looking at this again, it doesn't seem quite correct. The thread_local is set once but of course you can more than one Environment per isolate.
It's currently mostly academic because StartNodeInstance() is only called from Start() but still.
Sorry, something went wrong.
There was a problem hiding this comment.
Unnecessary whitespace change.
Sorry, something went wrong.
There was a problem hiding this comment.
I'll remove this.
Sorry, something went wrong.
There was a problem hiding this comment.
For the record, I'd be okay with switching this a std::list<...>. Could be a separate commit or pull request.
Sorry, something went wrong.
There was a problem hiding this comment.
Sounds good, let me do that in a separate PR.
Sorry, something went wrong.
I'll take another look into this |
Sorry, something went wrong.
|
Rebased with upstream master. Running CI again to see how much damage I've cause when updating node.gyp: This does not address @bnoordhuis point that Start can be called multiple times. I'll take a look at this next. |
Sorry, something went wrong.
Sorry about the delay on this. I've tried to address the issue of having multiple Environments per Isolate for the use case when Node is being embedded (see 45248a4d5f1794174a44a56186c5d9266ff75087 for details). I'm trying to understand the other case when node::Start would be called multiple times. I've started by trying to create a test that calls node::Start multiple times it but failed quite early. The error reported is: $ make cctest GTEST_FILTER=NodeTest.*
Note: Google Test filter = NodeTest.*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from NodeTest
[ RUN ] NodeTest.StartMultipleTimes
#
# Fatal error in ../deps/v8/src/v8.cc, line 94
# Check failed: !platform_.
#
==== C stack trace ===============================
0 cctest 0x0000000100325b4e v8::base::debug::StackTrace::StackTrace() + 30
1 cctest 0x0000000100325b85 v8::base::debug::StackTrace::StackTrace() + 21
2 cctest 0x000000010031e914 V8_Fatal + 452
3 cctest 0x00000001010c996d v8::internal::V8::InitializePlatform(v8::Platform*) + 77
4 cctest 0x000000010035e8e5 v8::V8::InitializePlatform(v8::Platform*) + 21
5 cctest 0x0000000100033b20 _ZN4node3$_010InitializeEi + 48
6 cctest 0x000000010003371e node::Start(int, char**) + 158
7 cctest 0x00000001000cee4f startNode(void*) + 31
8 libsystem_pthread.dylib 0x00007fff8423a99d _pthread_body + 131
9 libsystem_pthread.dylib 0x00007fff8423a91a _pthread_body + 0
10 libsystem_pthread.dylib 0x00007fff84238351 thread_start + 13
make: *** [cctest] Illegal instruction: 4I know @bnoordhuis said that it was mostly academic, and I'm wondering if this is worth pursuing? Also, adding a cctest that used Node core bits was interesting and took a while to get it to pass on all platforms. Would it make sense to clean up test: enable gtest that use node core code and add this separately or is there any policy to avoid cctest in favour of other tests? |
Sorry, something went wrong.
|
Can you squash into logical commits? I understand you made some additional changes but the history is kind of hard to follow. |
Sorry, something went wrong.
|
@bnoordhuis Sorry about that, most of them came about as I was trying to figure out how to get the test passing on the various platforms (after adding a test to cctest). |
Sorry, something went wrong.
this is a re-base of the gyp part of 6a09a69 after bumping GYP version to https://chromium.googlesource.com/external/gyp/+/eb296f67da078ec01f5e3a9ea9cdc6d26d680161 Original-PR-URL: #11956 Original-Ref: #9163 Original-Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #12450 Reviewed-By: João Reis <reis@janeasystems.com>
|
This is not landing cleanly on v7.x-staging. Mind submitting a backport PR? |
Sorry, something went wrong.
|
@evanlucas I'll try to take a look at this tomorrow |
Sorry, something went wrong.
this is a re-base of the gyp part of 6a09a69 after bumping GYP version to https://chromium.googlesource.com/external/gyp/+/eb296f67da078ec01f5e3a9ea9cdc6d26d680161 Original-PR-URL: #11956 Original-Ref: #9163 Original-Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #12450 Reviewed-By: João Reis <reis@janeasystems.com>
this is a re-base of the gyp part of 6a09a69 after bumping GYP version to https://chromium.googlesource.com/external/gyp/+/eb296f67da078ec01f5e3a9ea9cdc6d26d680161 Original-PR-URL: #11956 Original-Ref: #9163 Original-Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #12450 Reviewed-By: João Reis <reis@janeasystems.com>
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>
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>
|
For right now @nodejs/lts decided to not land this as we didn't see a specific reason to backport. If this may be mistaken please let us know |
Sorry, something went wrong.
|
Looks like this causes an issue with electron, see electron/electron#11299 (comment). I don't know enough about this PR to be able to comment on whether the solution proposed in that thread is a good idea or not, but maybe @danbev @addaleax or @bnoordhuis might be able to offer some advice there. |
Sorry, something went wrong.
|
@gibfahn I'll take a closer look at this (hopefully later today or tomorrow). |
Sorry, something went wrong.
|
I've started to look into this, but won't be working for the next few (sick kid), but I'll revisit as soon as I'm back. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
src
Description of change
This commit attempts to address one of the TODOs in
#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..