Skip to content

Commit 991a977

Browse files
authored
chore: cherry-pick 6 changes from chromium and v8 (#52396)
1 parent 3991da0 commit 991a977

8 files changed

Lines changed: 1086 additions & 0 deletions

‎patches/chromium/.patches‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,8 @@ cherry-pick-45d7457ac585.patch
330330
cherry-pick-7aea889dfa2f.patch
331331
cherry-pick-e6468cc124d6.patch
332332
cherry-pick-873978ddc92b.patch
333+
cherry-pick-e74ba1a76dd5.patch
334+
cherry-pick-d559d5018b66.patch
335+
cherry-pick-094448afb6ab.patch
336+
cherry-pick-e3cd72e404a5.patch
337+
cherry-pick-64f023ac1648.patch
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Maks Orlovich <[email protected]>
3+
Date: Wed, 15 Jul 2026 09:05:33 -0700
4+
Subject: [M150] SimpleCache: fix problems with self-deletion in post-doom
5+
callbacks
6+
7+
Original change's description:
8+
> SimpleCache: fix problems with self-deletion in post-doom callbacks
9+
>
10+
> Fixed: 533446300
11+
> Change-Id: I130245edb091f1d48437d74a59aa012667a6227b
12+
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8074044
13+
> Reviewed-by: Josh Karlin <[email protected]>
14+
> Commit-Queue: Maks Orlovich <[email protected]>
15+
> Cr-Commit-Position: refs/heads/main@{#1661113}
16+
17+
(cherry picked from commit 7b15c3bbc9632e9868e4c10a32133cd82a024f12;
18+
merge seems to have introduced conflicts by pulling in tests that are
19+
not in 150 (https://chromiumdash.appspot.com/commit/4373dfc5ccebd3829ad0f0d0b1ebd93550dd321a), not sure why)
20+
21+
Bug: 534618158,533446300
22+
Change-Id: I130245edb091f1d48437d74a59aa012667a6227b
23+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8091747
24+
Reviewed-by: Josh Karlin <[email protected]>
25+
Commit-Queue: Maks Orlovich <[email protected]>
26+
Cr-Commit-Position: refs/branch-heads/7871@{#3473}
27+
Cr-Branched-From: f542126b8c1b3e80104b26bb05ec830bd1206f29-refs/heads/main@{#1639810}
28+
29+
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
30+
index 40d20bfea85841c3eeeb097b66cf1683cd8c40a9..45b00beb9cdb91c884052a6817f0df88b0830e4b 100644
31+
--- a/net/disk_cache/backend_unittest.cc
32+
+++ b/net/disk_cache/backend_unittest.cc
33+
@@ -5968,6 +5968,67 @@ TEST_P(DiskCacheGenericBackendTest, BackendDoomNonExistentEntry) {
34+
}
35+
}
36+
37+
+TEST_P(DiskCacheGenericBackendTest, DeleteBackendWithMassDoom) {
38+
+ if (backend_to_test() == BackendToTest::kMemory) {
39+
+ // Uninteresting w/memory since the delete is synchronous.
40+
+ return;
41+
+ }
42+
+
43+
+ SetCacheType(net::APP_CACHE); // no optimistic ops.
44+
+
45+
+ InitCache();
46+
+ for (int i = 0; i < 100; ++i) {
47+
+ disk_cache::Entry* entry = nullptr;
48+
+ ASSERT_THAT(CreateEntry(base::NumberToString(i), &entry), IsOk());
49+
+ entry->Close();
50+
+ }
51+
+ // Get closes to actually close.
52+
+ FlushQueueForTest();
53+
+ net::TestCompletionCallback cb;
54+
+
55+
+ // Kick off a doom.
56+
+ int rv = cache_->DoomAllEntries(cb.callback());
57+
+ EXPECT_EQ(net::ERR_IO_PENDING, rv);
58+
+ // We need to go to event loop since DoomAllEntries in Simple has async index
59+
+ // readiness hop, but we don't want to flush all the threads.
60+
+ base::RunLoop().RunUntilIdle();
61+
+
62+
+ base::RunLoop run_loop;
63+
+
64+
+ // Try to open a couple of entries, and delete it in the first callback that
65+
+ // gets invoked. The second open should be safe since we don't go to event
66+
+ // loop between the calls, so the callback can't be delivered yet. Also only
67+
+ // one of the callbacks should be invoked per the cancellation semantics.
68+
+ EntryResult result0 = cache_->OpenEntry(
69+
+ "0", net::HIGHEST, base::BindLambdaForTesting([&](EntryResult result) {
70+
+ EXPECT_EQ(net::ERR_FAILED, result.net_error());
71+
+ TakeCache();
72+
+ run_loop.Quit();
73+
+ }));
74+
+ if (result0.net_error() == net::ERR_FAILED) {
75+
+ // If the delete finished already to the point the open fails synchronously,
76+
+ // we can't really test anything, so don't proceed.
77+
+ return;
78+
+ }
79+
+ EXPECT_EQ(result0.net_error(), net::ERR_IO_PENDING);
80+
+
81+
+ EntryResult result1 = cache_->OpenEntry(
82+
+ "1", net::HIGHEST, base::BindLambdaForTesting([&](EntryResult result) {
83+
+ EXPECT_EQ(net::ERR_FAILED, result.net_error());
84+
+ TakeCache();
85+
+ run_loop.Quit();
86+
+ }));
87+
+ if (result1.net_error() == net::ERR_FAILED) {
88+
+ // If the delete finished already to the point the open fails synchronously,
89+
+ // we can't really test anything, so don't proceed.
90+
+ return;
91+
+ }
92+
+ EXPECT_EQ(result1.net_error(), net::ERR_IO_PENDING);
93+
+
94+
+ EXPECT_EQ(net::OK, cb.GetResult(rv));
95+
+ run_loop.Run();
96+
+}
97+
+
98+
INSTANTIATE_TEST_SUITE_P(
99+
/* no name */,
100+
DiskCacheGenericBackendTest,
101+
diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc
102+
index b83b96bdca1cb7b59396cea23568c91cec8da821..d51628718ccf74956a1e0f73fad4ff52c9f1a2b3 100644
103+
--- a/net/disk_cache/simple/simple_backend_impl.cc
104+
+++ b/net/disk_cache/simple/simple_backend_impl.cc
105+
@@ -915,8 +915,12 @@ void SimpleBackendImpl::DoomEntriesComplete(
106+
std::unique_ptr<std::vector<uint64_t>> entry_hashes,
107+
CompletionOnceCallback callback,
108+
int result) {
109+
+ // Save `post_doom_waiting_` locally in case something invoked from us
110+
+ // deletes `this`.
111+
+ scoped_refptr<SimplePostOperationWaiterTable> post_doom_waiting =
112+
+ post_doom_waiting_;
113+
for (const uint64_t& entry_hash : *entry_hashes)
114+
- post_doom_waiting_->OnOperationComplete(entry_hash);
115+
+ post_doom_waiting->OnOperationComplete(entry_hash);
116+
std::move(callback).Run(result);
117+
}
118+
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Tom Anderson <[email protected]>
3+
Date: Tue, 14 Jul 2026 10:22:15 -0700
4+
Subject: [M150] [aura] Guard against root window destruction in
5+
ScopedCursorHider
6+
7+
Original change's description:
8+
> [aura] Guard against root window destruction in ScopedCursorHider
9+
>
10+
> Avoid Use-After-Free during device scale factor changes on Linux/X11 by
11+
> using an aura::WindowTracker inside
12+
> ScopedCursorHider::~ScopedCursorHider(). Previously,
13+
> display::Screen::Get()->GetDisplayNearestWindow() could synchronously
14+
> dispatch events that tear down the root window and the CursorClient. By
15+
> tracking window destruction, the window is verified to be alive after
16+
> returning from display queries before making calls on the CursorClient.
17+
>
18+
> Fixed: 532970574
19+
> Change-Id: I495fa5f12bf0a58fb047009d792366879e75521b
20+
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8072900
21+
> Commit-Queue: Thomas Anderson <[email protected]>
22+
> Reviewed-by: Colin Blundell <[email protected]>
23+
> Cr-Commit-Position: refs/heads/main@{#1661444}
24+
25+
(cherry picked from commit d5f0488a4d6a4a7fd8d4941d748b5d6112bb40c9)
26+
27+
Bug: 534618099,532970574
28+
Change-Id: I495fa5f12bf0a58fb047009d792366879e75521b
29+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8092250
30+
Reviewed-by: Avi Drissman <[email protected]>
31+
Commit-Queue: Thomas Anderson <[email protected]>
32+
Cr-Commit-Position: refs/branch-heads/7871@{#3417}
33+
Cr-Branched-From: f542126b8c1b3e80104b26bb05ec830bd1206f29-refs/heads/main@{#1639810}
34+
35+
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
36+
index 00f951491f7d0e32aa5fa25ce5dbdfe7e282372d..2c08b169b4c79b6a62b7046e49f0859748b9f598 100644
37+
--- a/ui/aura/window.cc
38+
+++ b/ui/aura/window.cc
39+
@@ -148,18 +148,31 @@ class ScopedCursorHider {
40+
ScopedCursorHider& operator=(const ScopedCursorHider&) = delete;
41+
42+
~ScopedCursorHider() {
43+
- if (!window_->IsRootWindow())
44+
+ // Store the raw window pointer in a local variable and clear the `window_`
45+
+ // raw_ptr to nullptr before carrying out the rest of the destructor. Since
46+
+ // the window can be synchronously destroyed inside display query sink calls
47+
+ // below, clearing the raw_ptr while the window is still alive prevents
48+
+ // Chromium's dangling raw_ptr checks from triggering on destruction.
49+
+ Window* window = window_;
50+
+ window_ = nullptr;
51+
+
52+
+ if (!window->IsRootWindow()) {
53+
return;
54+
+ }
55+
56+
// Update the device scale factor of the cursor client only when the last
57+
// mouse location is on this root window.
58+
if (hid_cursor_) {
59+
- client::CursorClient* cursor_client = client::GetCursorClient(window_);
60+
- if (cursor_client) {
61+
- const display::Display& display =
62+
- display::Screen::Get()->GetDisplayNearestWindow(window_);
63+
- cursor_client->SetDisplay(display);
64+
- cursor_client->ShowCursor();
65+
+ aura::WindowTracker tracker;
66+
+ tracker.Add(window);
67+
+ const display::Display& display =
68+
+ display::Screen::Get()->GetDisplayNearestWindow(window);
69+
+ if (tracker.Contains(window)) {
70+
+ client::CursorClient* cursor_client = client::GetCursorClient(window);
71+
+ if (cursor_client) {
72+
+ cursor_client->SetDisplay(display);
73+
+ cursor_client->ShowCursor();
74+
+ }
75+
}
76+
}
77+
}
78+
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
79+
index c59b14ef0962a847d5cd1f446bbc653dca3fdcfa..0c21e77e810f5680b8af352fda08673565906969 100644
80+
--- a/ui/aura/window_unittest.cc
81+
+++ b/ui/aura/window_unittest.cc
82+
@@ -22,6 +22,7 @@
83+
#include "cc/trees/layer_tree_frame_sink.h"
84+
#include "testing/gtest/include/gtest/gtest.h"
85+
#include "ui/aura/client/capture_client.h"
86+
+#include "ui/aura/client/cursor_client.h"
87+
#include "ui/aura/client/focus_change_observer.h"
88+
#include "ui/aura/client/visibility_client.h"
89+
#include "ui/aura/client/window_parenting_client.h"
90+
@@ -30,6 +31,7 @@
91+
#include "ui/aura/scoped_window_event_targeting_blocker.h"
92+
#include "ui/aura/test/aura_test_base.h"
93+
#include "ui/aura/test/aura_test_utils.h"
94+
+#include "ui/aura/test/test_cursor_client.h"
95+
#include "ui/aura/test/test_window_delegate.h"
96+
#include "ui/aura/test/test_windows.h"
97+
#include "ui/aura/test/window_test_api.h"
98+
@@ -4078,6 +4080,106 @@ TEST_P(WindowActualScreenBoundsTest, VerifyWindowActualBoundsDuringAnimation) {
99+
bounds_checker.WaitForAnimationCompletion();
100+
}
101+
102+
+class ReentrantDisplayScreen : public display::Screen {
103+
+ public:
104+
+ explicit ReentrantDisplayScreen(display::Screen* original_screen,
105+
+ base::RepeatingClosure on_get_display)
106+
+ : original_screen_(original_screen),
107+
+ on_get_display_(std::move(on_get_display)) {
108+
+ set_shutdown(true);
109+
+ }
110+
+
111+
+ ReentrantDisplayScreen(const ReentrantDisplayScreen&) = delete;
112+
+ ReentrantDisplayScreen& operator=(const ReentrantDisplayScreen&) = delete;
113+
+
114+
+ ~ReentrantDisplayScreen() override = default;
115+
+
116+
+ // Overridden from display::Screen:
117+
+ gfx::Point GetCursorScreenPoint() override {
118+
+ return original_screen_->GetCursorScreenPoint();
119+
+ }
120+
+ bool IsWindowUnderCursor(gfx::NativeWindow window) override {
121+
+ return original_screen_->IsWindowUnderCursor(window);
122+
+ }
123+
+ gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
124+
+ return original_screen_->GetWindowAtScreenPoint(point);
125+
+ }
126+
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
127+
+ const gfx::Point& point,
128+
+ const std::set<gfx::NativeWindow>& ignore) override {
129+
+ return original_screen_->GetLocalProcessWindowAtPoint(point, ignore);
130+
+ }
131+
+ int GetNumDisplays() const override {
132+
+ return original_screen_->GetNumDisplays();
133+
+ }
134+
+ const std::vector<display::Display>& GetAllDisplays() const override {
135+
+ return original_screen_->GetAllDisplays();
136+
+ }
137+
+ display::Display GetDisplayNearestWindow(
138+
+ gfx::NativeWindow window) const override {
139+
+ on_get_display_.Run();
140+
+ return original_screen_->GetDisplayNearestWindow(window);
141+
+ }
142+
+ display::Display GetDisplayNearestPoint(
143+
+ const gfx::Point& point) const override {
144+
+ return original_screen_->GetDisplayNearestPoint(point);
145+
+ }
146+
+ display::Display GetDisplayMatching(
147+
+ const gfx::Rect& match_rect) const override {
148+
+ return original_screen_->GetDisplayMatching(match_rect);
149+
+ }
150+
+ display::Display GetPrimaryDisplay() const override {
151+
+ return original_screen_->GetPrimaryDisplay();
152+
+ }
153+
+ void AddObserver(display::DisplayObserver* observer) override {
154+
+ original_screen_->AddObserver(observer);
155+
+ }
156+
+ void RemoveObserver(display::DisplayObserver* observer) override {
157+
+ original_screen_->RemoveObserver(observer);
158+
+ }
159+
+
160+
+ private:
161+
+ raw_ptr<display::Screen> original_screen_;
162+
+ base::RepeatingClosure on_get_display_;
163+
+};
164+
+
165+
+TEST_F(WindowTest, ScopedCursorHiderCursorClientFreedDuringGetDisplay) {
166+
+ display::Screen* original_screen = display::Screen::Get();
167+
+
168+
+ std::unique_ptr<Window> test_root = std::make_unique<Window>(nullptr);
169+
+ test_root->Init(ui::LAYER_NOT_DRAWN);
170+
+ test_root->set_host(host());
171+
+ test_root->SetBounds(gfx::Rect(0, 0, 800, 600));
172+
+
173+
+ TestCursorClient cursor_client(root_window());
174+
+ client::SetCursorClient(root_window(), nullptr);
175+
+ client::SetCursorClient(test_root.get(), &cursor_client);
176+
+
177+
+ Env::GetInstance()->SetLastMouseLocation(gfx::Point(10, 10));
178+
+
179+
+ cursor_client.ShowCursor();
180+
+ EXPECT_TRUE(cursor_client.IsCursorVisible());
181+
+
182+
+ ReentrantDisplayScreen reentrant_screen(
183+
+ original_screen,
184+
+ base::BindLambdaForTesting([&]() { test_root.reset(); }));
185+
+
186+
+ display::Screen::SetScreenInstance(&reentrant_screen);
187+
+
188+
+ // This call synchronously destroys `test_root` during the nested display
189+
+ // nearest window query. With the fix, the ScopedCursorHider destructor
190+
+ // detects this destruction via `WindowTracker` and avoids dereferencing the
191+
+ // freed `CursorClient` pointer or `test_root`, so this call should complete
192+
+ // without crashing.
193+
+ test_root->OnDeviceScaleFactorChanged(1.0f, 2.0f);
194+
+
195+
+ display::Screen::SetScreenInstance(nullptr);
196+
+ display::Screen::SetScreenInstance(original_screen);
197+
+
198+
+ // Restore cursor client.
199+
+ client::SetCursorClient(root_window(), &cursor_client);
200+
+}
201+
+
202+
} // namespace
203+
} // namespace test
204+
} // namespace aura

0 commit comments

Comments
 (0)