Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
report: add missing locks for report_on_fatalerror accessors#32535
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Overlooked in 2fa74e3. Refs: nodejs#32207
cjihrig left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'm assuming the same thing should be done in #32497?
nodejs-github-bot commented Mar 28, 2020
| } | ||
| staticvoidShouldReportOnFatalError(const FunctionCallbackInfo<Value>& info){ | ||
| Mutex::ScopedLock lock(node::per_process::cli_options_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will defining report_on_fatalerror as std::atomic<bool> be a better approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gireeshpunathil You could do that, but I doubt that it’s worth the extra complexity.
nodejs-github-bot commented Mar 30, 2020
sam-github commented Mar 30, 2020
This makes threads running js (workers and main) all get mutex on access via the js setter/getter, but don't all accesses to that value after the intial CLI parsing need protection? Specifically, Line 409 in accc984
|
sam-github commented Mar 30, 2020
Do Set/GetFipsCrypto have the same issues? I didn't do a thorough review, I just did some grepping for some of the other process scope options, and they appear to be subject to the same problem as the on_error. @gireeshpunathil 's atomic suggestion seems a pretty good one for all bools, it makes it safer by shifting the responsibility to the variable to be safe, rather than to the users of the variable. Atomic won't work for types that are not trivially copyable, though, so strings will need to use the mutex. |
Overlooked in 2fa74e3. Refs: #32207 PR-URL: #32535 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
addaleax commented Apr 2, 2020
Landed in e06512b @sam-github If you want to switch these over to using atomics, I think that’s okay – most importantly, I’d like to be consistent, and I’d like to be explicit about using global mutable state when we’re doing it. And yes, the FIPS accessors look like they should also be protected by a mutex. |
sam-github commented Apr 2, 2020
@addaleax Did you see #32535 (comment)? Is no locking required on the other access? Btw, I tried atomic bools, they aren't supported by the options parser, and adding an entire new specialization for the options parser didn't seem worth it. cc: @gireeshpunathil |
addaleax commented Apr 2, 2020
@sam-github Yeah, as I said to @gireeshpunathil – it doesn’t seem worth the extra complexity. And yes, I think technically the other accesses need a mutex, too. Thinking about it, #31717 introduced a mechanism for this that might actually help a lot here – wrapping the per-process options struct in |
sam-github commented Apr 2, 2020
I like the #31717 approach, though I suspect it would break the options parsing even more thoroughly than atomics. On the plus side, it would also handle std::string (which can't be atomic), so that's a win. |
addaleax commented Apr 2, 2020
@sam-github To be clear, my suggestion is to wrap the entire struct in |
Overlooked in 2fa74e3. Refs: #32207 PR-URL: #32535 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Overlooked in 2fa74e3. Refs: #32207 PR-URL: #32535 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Overlooked in 2fa74e3. Refs: nodejs#32207 PR-URL: nodejs#32535 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Overlooked in 2fa74e3. Refs: #32207 PR-URL: #32535 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Overlooked in 2fa74e3.
Refs: #32207
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes