Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! src: add check against non-weak BaseObjects at process exit
  • Loading branch information
addaleax committed Oct 4, 2020
commit 623ba9a602b169b29e5fb91215a4c6f49945a4ee
2 changes: 1 addition & 1 deletion src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct AsyncWrapObject : public AsyncWrap {
return tmpl;
}

bool IsAllowedStrongObjectAtExit() const override {
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
// We can't really know what the underlying operation does. One of the
// signs that it's time to remove this class. :)
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/base_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class BaseObject : public MemoryRetainer {

// Indicates whether this object is expected to use a strong reference during
// a clean process exit (due to an empty event loop).
virtual bool IsAllowedStrongObjectAtExit() const;
virtual bool IsNotIndicativeOfMemoryLeakAtExit() const;

virtual inline void OnGCCollect();

Expand Down
4 changes: 2 additions & 2 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ void Environment::VerifyNoStrongBaseObjects() {
if (!options()->verify_base_objects) return;

ForEachBaseObject([this](BaseObject* obj) {
if (obj->IsAllowedStrongObjectAtExit()) return;
if (obj->IsNotIndicativeOfMemoryLeakAtExit()) return;
fprintf(stderr, "Found bad BaseObject during clean exit: %s\n",
obj->MemoryInfoName().c_str());
fflush(stderr);
Expand Down Expand Up @@ -1494,7 +1494,7 @@ Local<FunctionTemplate> BaseObject::GetConstructorTemplate(Environment* env) {
return tmpl;
}

bool BaseObject::IsAllowedStrongObjectAtExit() const {
bool BaseObject::IsNotIndicativeOfMemoryLeakAtExit() const {
return IsWeakOrDetached();
}
Comment thread
addaleax marked this conversation as resolved.

Expand Down
2 changes: 1 addition & 1 deletion src/handle_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void HandleWrap::OnGCCollect() {
}


bool HandleWrap::IsAllowedStrongObjectAtExit() const {
bool HandleWrap::IsNotIndicativeOfMemoryLeakAtExit() const {
return IsWeakOrDetached() ||
!HandleWrap::HasRef(this) ||
!uv_is_active(GetHandle());
Expand Down
2 changes: 1 addition & 1 deletion src/handle_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class HandleWrap : public AsyncWrap {
AsyncWrap::ProviderType provider);
virtual void OnClose() {}
void OnGCCollect() final;
bool IsAllowedStrongObjectAtExit() const override;
bool IsNotIndicativeOfMemoryLeakAtExit() const override;

void MarkAsInitialized();
void MarkAsUninitialized();
Expand Down
2 changes: 1 addition & 1 deletion src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class JSBindingsConnection : public AsyncWrap {
SET_MEMORY_INFO_NAME(JSBindingsConnection)
SET_SELF_SIZE(JSBindingsConnection)

bool IsAllowedStrongObjectAtExit() const override {
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
return true; // Binding connections emit events on their own.
}

Expand Down
2 changes: 1 addition & 1 deletion src/module_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ModuleWrap : public BaseObject {
SET_MEMORY_INFO_NAME(ModuleWrap)
SET_SELF_SIZE(ModuleWrap)

bool IsAllowedStrongObjectAtExit() const override {
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
// XXX: The garbage collection rules for ModuleWrap are *super* unclear.
// Do these objects ever get GC'd? Are we just okay with leaking them?
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/node_contextify.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CompiledFnEntry final : public BaseObject {
v8::Local<v8::ScriptOrModule> script);
~CompiledFnEntry();

bool IsAllowedStrongObjectAtExit() const override { return true; }
bool IsNotIndicativeOfMemoryLeakAtExit() const override { return true; }

private:
uint32_t id_;
Expand Down
2 changes: 1 addition & 1 deletion src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ class Parser : public AsyncWrap, public StreamListener {
}


bool IsAllowedStrongObjectAtExit() const override {
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
// HTTP parsers are able to emit events without any GC root referring
// to them, because they receive events directly from the underlying
// libuv resource.
Expand Down
2 changes: 1 addition & 1 deletion src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ void Worker::MemoryInfo(MemoryTracker* tracker) const {
tracker->TrackField("parent_port", parent_port_);
}

bool Worker::IsAllowedStrongObjectAtExit() const {
bool Worker::IsNotIndicativeOfMemoryLeakAtExit() const {
// Worker objects always stay alive as long as the child thread, regardless
// of whether they are being referenced in the parent thread.
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/node_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Worker : public AsyncWrap {
void MemoryInfo(MemoryTracker* tracker) const override;
SET_MEMORY_INFO_NAME(Worker)
SET_SELF_SIZE(Worker)
bool IsAllowedStrongObjectAtExit() const override;
bool IsNotIndicativeOfMemoryLeakAtExit() const override;

bool is_stopped() const;

Expand Down
8 changes: 4 additions & 4 deletions src/stream_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ class SimpleShutdownWrap : public ShutdownWrap, public OtherBase {
SET_MEMORY_INFO_NAME(SimpleShutdownWrap)
SET_SELF_SIZE(SimpleShutdownWrap)

bool IsAllowedStrongObjectAtExit() const override {
return OtherBase::IsAllowedStrongObjectAtExit();
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
return OtherBase::IsNotIndicativeOfMemoryLeakAtExit();
}
};

Expand All @@ -430,8 +430,8 @@ class SimpleWriteWrap : public WriteWrap, public OtherBase {
SET_MEMORY_INFO_NAME(SimpleWriteWrap)
SET_SELF_SIZE(SimpleWriteWrap)

bool IsAllowedStrongObjectAtExit() const override {
return OtherBase::IsAllowedStrongObjectAtExit();
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
return OtherBase::IsNotIndicativeOfMemoryLeakAtExit();
}
};

Expand Down