Skip to content
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

chore: cherry-pick 2607ddacd643 from chromium #41573

Merged
merged 2 commits into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions patches/chromium/.patches
Expand Up @@ -131,3 +131,4 @@ fix_suppress_clang_-wimplicit-const-int-float-conversion_in.patch
cherry-pick-e7ffe20ebfac.patch
fix_getcursorscreenpoint_wrongly_returns_0_0.patch
fix_add_support_for_skipping_first_2_no-op_refreshes_in_thumb_cap.patch
cherry-pick-2607ddacd643.patch
38 changes: 38 additions & 0 deletions patches/chromium/cherry-pick-2607ddacd643.patch
@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Calvin Watford <watfordcalvin@gmail.com>
Date: Tue, 12 Mar 2024 20:37:32 +0000
Subject: Fix primary display race condition crash on Windows

In rare cases, it's possible for the OS to provide us a list of displays
that doesn't contain the primary display. This situation causes
undefined behavior (dereference past vector end) and a crash to occur in
|display::win::(anon)::DisplayInfosToScreenWinDisplays| on builds
without DCHECK enabled.

Bug: 40265302
Change-Id: I2154bedea84478a84147c380610c85d4ea3f703a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5353255
Reviewed-by: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: Robert Liao <robliao@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1271793}

diff --git a/ui/display/win/screen_win.cc b/ui/display/win/screen_win.cc
index 6b6189a124e3fde423b129ef34f2c96186b4e86d..1040e583c6c50ba01efc44faa1882657ff8f63b2 100644
--- a/ui/display/win/screen_win.cc
+++ b/ui/display/win/screen_win.cc
@@ -324,7 +324,13 @@ std::vector<ScreenWinDisplay> DisplayInfosToScreenWinDisplays(
display_infos_remaining, [](const internal::DisplayInfo& display_info) {
return display_info.screen_rect().origin().IsOrigin();
});
- DCHECK(primary_display_iter != display_infos_remaining.end());
+
+ // If we can't find the primary display, we likely witnessed a race condition
+ // when querying the OS for display info. We expect another OS notification to
+ // trigger this lookup again soon, so just return an empty list for now.
+ if (primary_display_iter == display_infos_remaining.end()) {
+ return {};
+ }

// Build the tree and determine DisplayPlacements along the way.
DisplayLayoutBuilder builder(primary_display_iter->id());