-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Fix dispose without checking #31260
Fix dispose without checking #31260
Conversation
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called.
0641ee3
to
4058d53
Compare
@@ -99,6 +107,10 @@ struct V8Platform { | |||
} | |||
|
|||
inline void Dispose() { | |||
if(!initialize_) |
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.
Disposing without initializing first sounds like a buggy use case to me. Why do we return instead of aborting here?
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.
Line 958 in bd6d651
DisposePlatform(); |
Here is the part that calls DisposePlatform globally.
If created through CreatePlatform then v8_platform is not initialized.
So should be ignored instead of Aborting.
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.
In that case I think the state should be maintained in the caller instead of in the callee..
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.
DrainTasks now run after RunAtExit has run.
Is this order of execution important?
If order is not important, I think can Dispose with AtExit.
@nodejs/v8 |
@Trott Fwiw, the embedders team is probably a better target for pings, if you want to notify somebody – I don’t quite know why the bot tagged this with V8, it’s not directly related. @jc-lab Thanks for bringing this up – I feel like the issue is a bit larger; in particular, currently we always initialize/tear down the platform in |
@@ -79,8 +80,15 @@ class NodeTraceStateObserver | |||
}; | |||
|
|||
struct V8Platform { | |||
bool initialize_; |
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.
@jc-lab Can you call this initialized_
and use a default initializer instead of adding a constructor? i.e.
bool initialize_; | |
bool initialized_ = false; |
@@ -99,6 +107,10 @@ struct V8Platform { | |||
} | |||
|
|||
inline void Dispose() { | |||
if(!initialize_) |
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.
if(!initialize_) | |
if (!initialized_) |
The bot tags on the names of the files changed. In this case it matched the following regular expression: |
@nodejs/embedders |
I’ve included this in #30467, along with a fixup commit for the comments above. |
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called. Refs: nodejs#31260
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called. Refs: #31260 Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called. Refs: nodejs#31260 Co-authored-by: Anna Henningsen <[email protected]> PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called. Backport-PR-URL: #35241 Refs: #31260 Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called.
node/src/env.cc
Line 958 in bd6d651
node/src/node_v8_platform-inl.h
Lines 176 to 178 in bd6d651