Commit 88d5b904 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

cppgc-js: Fix leak in generating heap snapshots

StateBase requires a virtual destructor as it is destroyed through the
base class. Failing to provide a virtual dtor leaks internal state in
State (and possible in future RootState).

Bug: chromium:1056170
Change-Id: I4408a57dc05fdeb81408f571dd6eb87312ba7c9d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2964815Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75160}
parent f3810dd9
......@@ -106,6 +106,7 @@ class StateBase {
visited_(visited) {
DCHECK_NE(Visibility::kDependentVisibility, visibility);
}
virtual ~StateBase() = default;
// Visited objects have already been processed or are currently being
// processed, see also IsPending() below.
......@@ -189,6 +190,7 @@ class State final : public StateBase {
public:
State(const HeapObjectHeader& header, size_t state_count)
: StateBase(&header, state_count, Visibility::kHidden, nullptr, false) {}
~State() final = default;
const HeapObjectHeader* header() const {
return static_cast<const HeapObjectHeader*>(key_);
......@@ -276,6 +278,7 @@ class RootState final : public StateBase {
RootState(EmbedderRootNode* node, size_t state_count)
// Root states are always visited, visible, and have a node attached.
: StateBase(node, state_count, Visibility::kVisible, node, true) {}
~RootState() final = default;
};
// Abstraction for storing states. Storage allows for creation and lookup of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment