0

DanglingPointer: annotate for unittests base+linux [2/N]

Those are the leaked raw_ptr's. We detected those raw_ptr's as being
never released, and thus as being potential candidates to increase
pressure on the BRP memory quarantine.

Bug: 1400059
Change-Id: Id1f4799c1b3b4a3709b1ce19165c2fbb97313d67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4570897
Owners-Override: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Paul Semel <paulsemel@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1153261}
This commit is contained in:
Paul Semel
2023-06-05 16:10:44 +00:00
committed by Chromium LUCI CQ
parent 2a45690cdc
commit d3c00ef3dd
18 changed files with 37 additions and 31 deletions

@@ -257,7 +257,7 @@ class BASE_EXPORT HistogramSamples {
// external object. The callers guarantees the value will outlive this // external object. The callers guarantees the value will outlive this
// instance. // instance.
std::unique_ptr<Metadata> meta_owned_; std::unique_ptr<Metadata> meta_owned_;
raw_ptr<Metadata> meta_; raw_ptr<Metadata, LeakedDanglingUntriaged> meta_;
}; };
class BASE_EXPORT SampleCountIterator { class BASE_EXPORT SampleCountIterator {

@@ -900,7 +900,7 @@ class BASE_EXPORT DelayedPersistentAllocation {
// The underlying object that does the actual allocation of memory. Its // The underlying object that does the actual allocation of memory. Its
// lifetime must exceed that of all DelayedPersistentAllocation objects // lifetime must exceed that of all DelayedPersistentAllocation objects
// that use it. // that use it.
const raw_ptr<PersistentMemoryAllocator> allocator_; const raw_ptr<PersistentMemoryAllocator, LeakedDanglingUntriaged> allocator_;
// The desired type and size of the allocated segment plus the offset // The desired type and size of the allocated segment plus the offset
// within it for the defined request. // within it for the defined request.
@@ -912,7 +912,8 @@ class BASE_EXPORT DelayedPersistentAllocation {
// stored once the allocation is complete. If multiple delayed allocations // stored once the allocation is complete. If multiple delayed allocations
// share the same pointer then an allocation on one will amount to an // share the same pointer then an allocation on one will amount to an
// allocation for all. // allocation for all.
const raw_ptr<volatile std::atomic<Reference>> reference_; const raw_ptr<volatile std::atomic<Reference>, LeakedDanglingUntriaged>
reference_;
// No DISALLOW_COPY_AND_ASSIGN as it's okay to copy/move these objects. // No DISALLOW_COPY_AND_ASSIGN as it's okay to copy/move these objects.
}; };

@@ -98,13 +98,14 @@ class BASE_EXPORT PersistentSampleMap : public HistogramSamples {
// The allocator that manages histograms inside persistent memory. This is // The allocator that manages histograms inside persistent memory. This is
// owned externally and is expected to live beyond the life of this object. // owned externally and is expected to live beyond the life of this object.
raw_ptr<PersistentHistogramAllocator> allocator_; raw_ptr<PersistentHistogramAllocator, LeakedDanglingUntriaged> allocator_;
// The object that manages sample records inside persistent memory. This is // The object that manages sample records inside persistent memory. This is
// owned by the |allocator_| object (above) and so, like it, is expected to // owned by the |allocator_| object (above) and so, like it, is expected to
// live beyond the life of this object. This value is lazily-initialized on // live beyond the life of this object. This value is lazily-initialized on
// first use via the GetRecords() accessor method. // first use via the GetRecords() accessor method.
raw_ptr<PersistentSampleMapRecords> records_ = nullptr; raw_ptr<PersistentSampleMapRecords, LeakedDanglingUntriaged> records_ =
nullptr;
}; };
} // namespace base } // namespace base

@@ -113,7 +113,7 @@ class BASE_EXPORT SampleVectorBase : public HistogramSamples {
mutable std::atomic<HistogramBase::AtomicCount*> counts_{nullptr}; mutable std::atomic<HistogramBase::AtomicCount*> counts_{nullptr};
// Shares the same BucketRanges with Histogram object. // Shares the same BucketRanges with Histogram object.
const raw_ptr<const BucketRanges> bucket_ranges_; const raw_ptr<const BucketRanges, LeakedDanglingUntriaged> bucket_ranges_;
}; };
// A sample vector that uses local memory for the counts array. // A sample vector that uses local memory for the counts array.

@@ -186,11 +186,11 @@ class BookmarkMenuDelegate : public bookmarks::BaseBookmarkModelObserver,
// an id. // an id.
int GetAndIncrementNextMenuID(); int GetAndIncrementNextMenuID();
const raw_ptr<Browser> browser_; const raw_ptr<Browser, LeakedDanglingUntriaged> browser_;
raw_ptr<Profile> profile_; raw_ptr<Profile, LeakedDanglingUntriaged> profile_;
// Parent of menus. // Parent of menus.
raw_ptr<views::Widget> parent_; raw_ptr<views::Widget, LeakedDanglingUntriaged> parent_;
// Maps from menu id to BookmarkNode. // Maps from menu id to BookmarkNode.
MenuIDToNodeMap menu_id_to_node_map_; MenuIDToNodeMap menu_id_to_node_map_;

@@ -34,7 +34,7 @@ class PriceTrackingView : public views::FlexLayoutView {
raw_ptr<views::Label> body_label_; raw_ptr<views::Label> body_label_;
raw_ptr<views::ToggleButton> toggle_button_; raw_ptr<views::ToggleButton> toggle_button_;
raw_ptr<Profile> profile_; raw_ptr<Profile, LeakedDanglingUntriaged> profile_;
bool is_price_track_enabled_; bool is_price_track_enabled_;
base::WeakPtrFactory<PriceTrackingView> weak_ptr_factory_{this}; base::WeakPtrFactory<PriceTrackingView> weak_ptr_factory_{this};

@@ -110,7 +110,7 @@ class FakeTabSlotController : public TabSlotController {
} }
private: private:
raw_ptr<TabStripController> tab_strip_controller_; raw_ptr<TabStripController, LeakedDanglingUntriaged> tab_strip_controller_;
raw_ptr<TabContainer, DanglingUntriaged> tab_container_; raw_ptr<TabContainer, DanglingUntriaged> tab_container_;
ui::ListSelectionModel selection_model_; ui::ListSelectionModel selection_model_;
raw_ptr<Tab, DanglingUntriaged> active_tab_ = nullptr; raw_ptr<Tab, DanglingUntriaged> active_tab_ = nullptr;

@@ -139,8 +139,8 @@ class ResourceRequestAllowedNotifier
raw_ptr<Observer> observer_; raw_ptr<Observer> observer_;
NetworkConnectionTrackerGetter network_connection_tracker_getter_; NetworkConnectionTrackerGetter network_connection_tracker_getter_;
raw_ptr<network::NetworkConnectionTracker> network_connection_tracker_ = raw_ptr<network::NetworkConnectionTracker, LeakedDanglingUntriaged>
nullptr; network_connection_tracker_ = nullptr;
network::mojom::ConnectionType connection_type_ = network::mojom::ConnectionType connection_type_ =
network::mojom::ConnectionType::CONNECTION_UNKNOWN; network::mojom::ConnectionType::CONNECTION_UNKNOWN;
bool connection_initialized_ = false; bool connection_initialized_ = false;

@@ -1170,7 +1170,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// An expiry time for resetting the pending_user_activation_timer_. // An expiry time for resetting the pending_user_activation_timer_.
static const base::TimeDelta kActivationNotificationExpireTime; static const base::TimeDelta kActivationNotificationExpireTime;
raw_ptr<FrameTree> frame_tree_; raw_ptr<FrameTree, LeakedDanglingUntriaged> frame_tree_;
// RenderWidgetHost are either: // RenderWidgetHost are either:
// - Owned by RenderViewHostImpl. // - Owned by RenderViewHostImpl.
@@ -1212,7 +1212,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// dynamically fetching it from `site_instance_group_` since its // dynamically fetching it from `site_instance_group_` since its
// value gets cleared early in `SiteInstanceGroup` via // value gets cleared early in `SiteInstanceGroup` via
// RenderProcessHostDestroyed before this object is destroyed. // RenderProcessHostDestroyed before this object is destroyed.
const raw_ref<AgentSchedulingGroupHost> agent_scheduling_group_; const raw_ref<AgentSchedulingGroupHost, LeakedDanglingUntriaged>
agent_scheduling_group_;
// The SiteInstanceGroup this RenderWidgetHost belongs to. // The SiteInstanceGroup this RenderWidgetHost belongs to.
// TODO(https://crbug.com/1420333) Turn this into base::SafeRef // TODO(https://crbug.com/1420333) Turn this into base::SafeRef

@@ -37,7 +37,7 @@ class GIN_EXPORT NamedPropertyInterceptor {
v8::Isolate* isolate); v8::Isolate* isolate);
private: private:
raw_ptr<v8::Isolate> isolate_; raw_ptr<v8::Isolate, LeakedDanglingUntriaged> isolate_;
raw_ptr<WrappableBase> base_; raw_ptr<WrappableBase> base_;
}; };
@@ -59,7 +59,7 @@ class GIN_EXPORT IndexedPropertyInterceptor {
v8::Isolate* isolate); v8::Isolate* isolate);
private: private:
raw_ptr<v8::Isolate> isolate_; raw_ptr<v8::Isolate, LeakedDanglingUntriaged> isolate_;
raw_ptr<WrappableBase> base_; raw_ptr<WrappableBase> base_;
}; };

@@ -120,7 +120,8 @@ class MojoVideoDecoder final : public VideoDecoder,
// Manages VideoFrame destruction callbacks. // Manages VideoFrame destruction callbacks.
scoped_refptr<MojoVideoFrameHandleReleaser> mojo_video_frame_handle_releaser_; scoped_refptr<MojoVideoFrameHandleReleaser> mojo_video_frame_handle_releaser_;
raw_ptr<GpuVideoAcceleratorFactories> gpu_factories_ = nullptr; raw_ptr<GpuVideoAcceleratorFactories, LeakedDanglingUntriaged>
gpu_factories_ = nullptr;
// Raw pointer is safe since both `this` and the `media_log` are owned by // Raw pointer is safe since both `this` and the `media_log` are owned by
// WebMediaPlayerImpl with the correct declaration order. // WebMediaPlayerImpl with the correct declaration order.

@@ -101,10 +101,11 @@ class MEDIA_MOJO_EXPORT MojoVideoDecoderService final
std::string codec_string_; std::string codec_string_;
// Decoder factory. // Decoder factory.
raw_ptr<MojoMediaClient> mojo_media_client_; raw_ptr<MojoMediaClient, LeakedDanglingUntriaged> mojo_media_client_;
// A helper object required to get the CDM from a CDM ID. // A helper object required to get the CDM from a CDM ID.
const raw_ptr<MojoCdmServiceContext> mojo_cdm_service_context_ = nullptr; const raw_ptr<MojoCdmServiceContext, LeakedDanglingUntriaged>
mojo_cdm_service_context_ = nullptr;
// Channel for sending async messages to the client. // Channel for sending async messages to the client.
mojo::AssociatedRemote<mojom::VideoDecoderClient> client_; mojo::AssociatedRemote<mojom::VideoDecoderClient> client_;

@@ -179,8 +179,9 @@ class TestReportingContext : public ReportingContext {
// Owned by the DeliveryAgent and GarbageCollector, respectively, but // Owned by the DeliveryAgent and GarbageCollector, respectively, but
// referenced here to preserve type: // referenced here to preserve type:
raw_ptr<base::MockOneShotTimer> delivery_timer_; raw_ptr<base::MockOneShotTimer, LeakedDanglingUntriaged> delivery_timer_;
raw_ptr<base::MockOneShotTimer> garbage_collection_timer_; raw_ptr<base::MockOneShotTimer, LeakedDanglingUntriaged>
garbage_collection_timer_;
}; };
// A unit test base class that provides a TestReportingContext and shorthand // A unit test base class that provides a TestReportingContext and shorthand

@@ -31,7 +31,7 @@ class FileAvail : public FX_FILEAVAIL {
return file_avail->doc_loader_->IsDataAvailable(offset, size); return file_avail->doc_loader_->IsDataAvailable(offset, size);
} }
raw_ptr<DocumentLoader> doc_loader_; raw_ptr<DocumentLoader, LeakedDanglingUntriaged> doc_loader_;
}; };
class DownloadHints : public FX_DOWNLOADHINTS { class DownloadHints : public FX_DOWNLOADHINTS {
@@ -51,7 +51,7 @@ class DownloadHints : public FX_DOWNLOADHINTS {
return download_hints->doc_loader_->RequestData(offset, size); return download_hints->doc_loader_->RequestData(offset, size);
} }
raw_ptr<DocumentLoader> doc_loader_; raw_ptr<DocumentLoader, LeakedDanglingUntriaged> doc_loader_;
}; };
class FileAccess : public FPDF_FILEACCESS { class FileAccess : public FPDF_FILEACCESS {
@@ -73,7 +73,7 @@ class FileAccess : public FPDF_FILEACCESS {
return file_access->doc_loader_->GetBlock(position, size, buffer); return file_access->doc_loader_->GetBlock(position, size, buffer);
} }
raw_ptr<DocumentLoader> doc_loader_; raw_ptr<DocumentLoader, LeakedDanglingUntriaged> doc_loader_;
}; };
} // namespace } // namespace

@@ -56,7 +56,7 @@ class WebSocket final {
const std::string& message, const std::string& message,
const net::NetworkTrafficAnnotationTag traffic_annotation); const net::NetworkTrafficAnnotationTag traffic_annotation);
const raw_ptr<HttpServer> server_; const raw_ptr<HttpServer, LeakedDanglingUntriaged> server_;
const raw_ptr<HttpConnection> connection_; const raw_ptr<HttpConnection> connection_;
std::unique_ptr<WebSocketEncoder> encoder_; std::unique_ptr<WebSocketEncoder> encoder_;
bool closed_; bool closed_;

@@ -20,8 +20,8 @@ constexpr int kPriorityFdWatch = G_PRIORITY_DEFAULT_IDLE - 10;
struct GLibWaylandSource : public GSource { struct GLibWaylandSource : public GSource {
// Note: The GLibWaylandSource is created and destroyed by GLib. So its // Note: The GLibWaylandSource is created and destroyed by GLib. So its
// constructor/destructor may or may not get called. // constructor/destructor may or may not get called.
raw_ptr<WaylandEventWatcherGlib> event_watcher; raw_ptr<WaylandEventWatcherGlib, LeakedDanglingUntriaged> event_watcher;
raw_ptr<GPollFD> poll_fd; raw_ptr<GPollFD, LeakedDanglingUntriaged> poll_fd;
}; };
gboolean WatchSourcePrepare(GSource* source, gint* timeout_ms) { gboolean WatchSourcePrepare(GSource* source, gint* timeout_ms) {

@@ -15,8 +15,8 @@ namespace {
struct GLibX11Source : public GSource { struct GLibX11Source : public GSource {
// Note: The GLibX11Source is created and destroyed by GLib. So its // Note: The GLibX11Source is created and destroyed by GLib. So its
// constructor/destructor may or may not get called. // constructor/destructor may or may not get called.
raw_ptr<x11::Connection> connection; raw_ptr<x11::Connection, LeakedDanglingUntriaged> connection;
raw_ptr<GPollFD> poll_fd; raw_ptr<GPollFD, LeakedDanglingUntriaged> poll_fd;
}; };
gboolean XSourcePrepare(GSource* source, gint* timeout_ms) { gboolean XSourcePrepare(GSource* source, gint* timeout_ms) {

@@ -201,7 +201,7 @@ class WEBVIEW_EXPORT WebView : public View,
// Set to true when |holder_| is letterboxed (scaled to be smaller than this // Set to true when |holder_| is letterboxed (scaled to be smaller than this
// view, to preserve its aspect ratio). // view, to preserve its aspect ratio).
bool is_letterboxing_ = false; bool is_letterboxing_ = false;
raw_ptr<content::BrowserContext> browser_context_; raw_ptr<content::BrowserContext, LeakedDanglingUntriaged> browser_context_;
bool allow_accelerators_ = false; bool allow_accelerators_ = false;
raw_ptr<View, DanglingUntriaged> crashed_overlay_view_ = nullptr; raw_ptr<View, DanglingUntriaged> crashed_overlay_view_ = nullptr;
bool is_primary_web_contents_for_window_ = false; bool is_primary_web_contents_for_window_ = false;