From cebec4c16bbfc94af5172f4b882ddfb75fe54bdf Mon Sep 17 00:00:00 2001 From: Mark Harmer Date: Thu, 21 Dec 2023 08:57:40 -0800 Subject: [PATCH] Add raw_ptr_exclusion annontations on raw pointers to support compiling debug builds Patch-Filename: add_raw_ptr_exclusion_annontations_on_raw_pointers_to_support.patch --- discord/discord_video_decoder.cc | 11 +++++++---- discord/discord_video_decoder.h | 3 ++- discord/discord_video_source.cc | 2 +- discord/overlay.h | 7 ++++++- discord/overlay_win.cc | 2 +- discord/public/electron_video_shared.h | 13 +++++++++---- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/discord/discord_video_decoder.cc b/discord/discord_video_decoder.cc index 411a8ab443dcc..0d316fd869138 100644 --- a/discord/discord_video_decoder.cc +++ b/discord/discord_video_decoder.cc @@ -81,8 +81,9 @@ class DiscordVideoDecoderMediaThread { void OnOutput(scoped_refptr<::media::VideoFrame> frame); ElectronPointer format_; - void* user_data_; - ::media::GpuVideoAcceleratorFactories* gpu_factories_{}; + DISCORD_RAW_PTR_EXCLUSION void* user_data_; + DISCORD_RAW_PTR_EXCLUSION ::media::GpuVideoAcceleratorFactories* + gpu_factories_{}; std::unique_ptr<::media::MediaLog> media_log_; std::unique_ptr<::media::VideoDecoder> video_decoder_; scoped_refptr media_task_runner_; @@ -260,11 +261,13 @@ void DiscordVideoDecoderMediaThread::DecodeOnMediaThread() { } } -void DiscordVideoDecoderMediaThread::OnDecodeDone(::media::DecoderStatus status) { +void DiscordVideoDecoderMediaThread::OnDecodeDone( + ::media::DecoderStatus status) { DCHECK(media_task_runner_->RunsTasksInCurrentSequence()); outstanding_decode_requests_--; - if (!status.is_ok() && status.code() != ::media::DecoderStatus::Codes::kAborted) { + if (!status.is_ok() && + status.code() != ::media::DecoderStatus::Codes::kAborted) { base::AutoLock auto_lock(lock_); has_error_ = true; diff --git a/discord/discord_video_decoder.h b/discord/discord_video_decoder.h index fd1ff251dd95b..60cf48013885e 100644 --- a/discord/discord_video_decoder.h +++ b/discord/discord_video_decoder.h @@ -33,7 +33,8 @@ class DiscordVideoDecoder : public ElectronObject { uint32_t timestamp) override; private: - DiscordVideoDecoderMediaThread* media_thread_state_{}; + DISCORD_RAW_PTR_EXCLUSION DiscordVideoDecoderMediaThread* + media_thread_state_{}; bool started_initialize_{false}; bool initialized_{false}; }; diff --git a/discord/discord_video_source.cc b/discord/discord_video_source.cc index bedb43e4d1dae..0a1932bf8fec7 100644 --- a/discord/discord_video_source.cc +++ b/discord/discord_video_source.cc @@ -71,7 +71,7 @@ class MediaStreamDiscordVideoSource::VideoSourceDelegate // |frame_callback_| is accessed on the IO thread. VideoCaptureDeliverFrameCB frame_callback_; - media::GpuVideoAcceleratorFactories* gpu_factories_; + DISCORD_RAW_PTR_EXCLUSION media::GpuVideoAcceleratorFactories* gpu_factories_; std::unique_ptr gpu_memory_buffer_support_; }; diff --git a/discord/overlay.h b/discord/overlay.h index 0a5ead97a89a0..7fb16fa6ec1c4 100644 --- a/discord/overlay.h +++ b/discord/overlay.h @@ -1,6 +1,11 @@ #include #include +// Support for Electron debug builds that enable checks for rawptr. +// Use our own definition to avoid conflicts with Chromium's PA +// RAW_PTR_EXCLUSION macro +#define DISCORD_RAW_PTR_EXCLUSION __attribute__((annotate("raw_ptr_exclusion"))) + namespace discord { class Overlay { @@ -12,7 +17,7 @@ class Overlay { uint32_t process_id_ = 0; bool send_function_loaded_ = false; - const void* send_function_ = nullptr; + DISCORD_RAW_PTR_EXCLUSION const void* send_function_ = nullptr; }; } // namespace discord diff --git a/discord/overlay_win.cc b/discord/overlay_win.cc index 5998369978aae..e3df1ebe03d4f 100644 --- a/discord/overlay_win.cc +++ b/discord/overlay_win.cc @@ -40,7 +40,7 @@ struct OverlayFrameData { uint32_t process_id; uint32_t width; uint32_t height; - void* data; + DISCORD_RAW_PTR_EXCLUSION void* data; size_t length; }; diff --git a/discord/public/electron_video_shared.h b/discord/public/electron_video_shared.h index 8a7b60867f35f..7002c4d607cf4 100644 --- a/discord/public/electron_video_shared.h +++ b/discord/public/electron_video_shared.h @@ -18,8 +18,13 @@ #define ELECTRON_VIDEO_EXPORT #endif +// Support for Electron debug builds that enable checks for rawptr. +// Use our own definition to avoid conflicts with Chromium's PA +// RAW_PTR_EXCLUSION macro +#define DISCORD_RAW_PTR_EXCLUSION __attribute__((annotate("raw_ptr_exclusion"))) + namespace webrtc { - class I420BufferInterface; +class I420BufferInterface; } namespace discord { @@ -163,7 +168,7 @@ class ElectronPointer final { } } - T* electronObject_; + DISCORD_RAW_PTR_EXCLUSION T* electronObject_; }; template @@ -438,9 +443,9 @@ struct DiscordFrame { union { DiscordYUVFrame yuv; #if defined(_WIN32) - void* texture_handle; + DISCORD_RAW_PTR_EXCLUSION void* texture_handle; #endif - IElectronVideoFrame* electron; + DISCORD_RAW_PTR_EXCLUSION IElectronVideoFrame* electron; } frame; int32_t width; int32_t height;