Skip to content

Commit 4ad543c

Browse files
authored
chore: cherry-pick 0dc563cbbca5 from chromium (#25239)
1 parent 2cf35c0 commit 4ad543c

3 files changed

+112
-0
lines changed

patches/chromium/.patches

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,7 @@ backport_1081722.patch
121121
backport_1073409.patch
122122
backport_1074340.patch
123123
cherry-pick-70579363ce7b.patch
124+
indexeddb_fix_crash_in_webidbgetdbnamescallbacksimpl.patch
125+
indexeddb_reset_async_tasks_in_webidbgetdbnamescallbacksimpl.patch
124126
cherry-pick-138b748dd0a4.patch
125127
cherry-pick-bee371eeaf66.patch
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Adrienne Walker <enne@chromium.org>
3+
Date: Tue, 4 Aug 2020 20:10:23 +0000
4+
Subject: indexeddb: fix crash in WebIDBGetDBNamesCallbacksImpl
5+
6+
Resolve() can end up freeing WebIDBGetDBNamesCallbacksImpl by throwing a
7+
mojo error that deletes the self-owned associated receiver that owns it.
8+
So, don't call any other functions after it.
9+
10+
As the promise resolver can only resolve/reject once, it is safe to
11+
not clear it.
12+
13+
(cherry picked from commit da90fc39f5ca0f8dc1c665fbabad8ec229826f89)
14+
15+
Bug: 1106682
16+
Change-Id: Iea943f3c5c1e57adb6ad399baff49522f54d264b
17+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311620
18+
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
19+
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
20+
Auto-Submit: enne <enne@chromium.org>
21+
Cr-Original-Commit-Position: refs/heads/master@{#790857}
22+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337096
23+
Reviewed-by: enne <enne@chromium.org>
24+
Commit-Queue: enne <enne@chromium.org>
25+
Cr-Commit-Position: refs/branch-heads/4147@{#1023}
26+
Cr-Branched-From: 16307825352720ae04d898f37efa5449ad68b606-refs/heads/master@{#768962}
27+
28+
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_factory.cc b/third_party/blink/renderer/modules/indexeddb/idb_factory.cc
29+
index c7b06b4c851b973e4933d6b7635ca7fd32936551..645e5cbf682c2a26f6a3e0742afb4e77c4388770 100644
30+
--- a/third_party/blink/renderer/modules/indexeddb/idb_factory.cc
31+
+++ b/third_party/blink/renderer/modules/indexeddb/idb_factory.cc
32+
@@ -105,7 +105,6 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks {
33+
promise_resolver_->Reject(MakeGarbageCollected<DOMException>(
34+
DOMExceptionCode::kUnknownError,
35+
"The databases() promise was rejected."));
36+
- promise_resolver_.Clear();
37+
}
38+
39+
void SuccessNamesAndVersionsList(
40+
@@ -129,7 +128,7 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks {
41+
ExecutionContext::From(promise_resolver_->GetScriptState()),
42+
&async_task_id_, "success");
43+
promise_resolver_->Resolve(name_and_version_list);
44+
- promise_resolver_.Clear();
45+
+ // Note: Resolve may cause |this| to be deleted.
46+
}
47+
48+
void SuccessStringList(const Vector<String>&) override { NOTREACHED(); }
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Adrienne Walker <enne@chromium.org>
3+
Date: Wed, 5 Aug 2020 00:44:52 +0000
4+
Subject: indexeddb: reset async tasks in ~WebIDBGetDBNamesCallbacksImpl
5+
6+
Since sometimes the WebIDBGetDBNamesCallbacksImpl can be destroyed when
7+
the promise is resolved, make sure that no code that could reference it
8+
is still around. Store the async task as an optional member so it can
9+
be cleared during the destructor.
10+
11+
Followup to:
12+
https://chromium-review.googlesource.com/c/chromium/src/+/2311620
13+
14+
(cherry picked from commit 4422ec665ddca3ac05ad90bac5d5ebee7cfc5536)
15+
16+
Bug: 1106682,1109467
17+
Change-Id: Id6a0ff0a3703fab94e9684e41f16d5a1bac20468
18+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321332
19+
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
20+
Commit-Queue: enne <enne@chromium.org>
21+
Auto-Submit: enne <enne@chromium.org>
22+
Cr-Original-Commit-Position: refs/heads/master@{#792121}
23+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337110
24+
Reviewed-by: enne <enne@chromium.org>
25+
Cr-Commit-Position: refs/branch-heads/4147@{#1029}
26+
Cr-Branched-From: 16307825352720ae04d898f37efa5449ad68b606-refs/heads/master@{#768962}
27+
28+
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_factory.cc b/third_party/blink/renderer/modules/indexeddb/idb_factory.cc
29+
index 645e5cbf682c2a26f6a3e0742afb4e77c4388770..e2d0d49bed36e567a76c5610855a139774254b36 100644
30+
--- a/third_party/blink/renderer/modules/indexeddb/idb_factory.cc
31+
+++ b/third_party/blink/renderer/modules/indexeddb/idb_factory.cc
32+
@@ -111,6 +111,7 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks {
33+
Vector<mojom::blink::IDBNameAndVersionPtr> names_and_versions) override {
34+
if (!promise_resolver_)
35+
return;
36+
+ DCHECK(!async_task_.has_value());
37+
38+
HeapVector<Member<IDBDatabaseInfo>> name_and_version_list;
39+
name_and_version_list.ReserveInitialCapacity(name_and_version_list.size());
40+
@@ -124,11 +125,12 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks {
41+
name_and_version_list.push_back(idb_info);
42+
}
43+
44+
- probe::AsyncTask async_task(
45+
+ async_task_.emplace(
46+
ExecutionContext::From(promise_resolver_->GetScriptState()),
47+
&async_task_id_, "success");
48+
promise_resolver_->Resolve(name_and_version_list);
49+
- // Note: Resolve may cause |this| to be deleted.
50+
+ // Note: Resolve may cause |this| to be deleted. async_task_ will be
51+
+ // completed in the destructor.
52+
}
53+
54+
void SuccessStringList(const Vector<String>&) override { NOTREACHED(); }
55+
@@ -190,6 +192,7 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks {
56+
57+
private:
58+
probe::AsyncTaskId async_task_id_;
59+
+ base::Optional<probe::AsyncTask> async_task_;
60+
Persistent<ScriptPromiseResolver> promise_resolver_;
61+
};
62+

0 commit comments

Comments
 (0)