-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ | |||||||
#include "tracing/node_trace_writer.h" | ||||||||
#include "tracing/trace_event.h" | ||||||||
#include "tracing/traced_value.h" | ||||||||
#include "util.h" | ||||||||
|
||||||||
namespace node { | ||||||||
|
||||||||
|
@@ -79,8 +80,15 @@ class NodeTraceStateObserver | |||||||
}; | ||||||||
|
||||||||
struct V8Platform { | ||||||||
bool initialize_; | ||||||||
|
||||||||
V8Platform() | ||||||||
: initialize_(false) {} | ||||||||
|
||||||||
#if NODE_USE_V8_PLATFORM | ||||||||
inline void Initialize(int thread_pool_size) { | ||||||||
CHECK(!initialize_); | ||||||||
initialize_ = true; | ||||||||
tracing_agent_ = std::make_unique<tracing::Agent>(); | ||||||||
node::tracing::TraceEventHelper::SetAgent(tracing_agent_.get()); | ||||||||
node::tracing::TracingController* controller = | ||||||||
|
@@ -99,6 +107,10 @@ struct V8Platform { | |||||||
} | ||||||||
|
||||||||
inline void Dispose() { | ||||||||
if(!initialize_) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Line 958 in bd6d651
Here is the part that calls DisposePlatform globally. If created through CreatePlatform then v8_platform is not initialized. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. DrainTasks now run after RunAtExit has run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
return; | ||||||||
initialize_ = false; | ||||||||
|
||||||||
StopTracingAgent(); | ||||||||
platform_->Shutdown(); | ||||||||
delete platform_; | ||||||||
|
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.