Skip to content

Commit c40082b

Browse files
committed
CrashTracer: com.apple.WebKit.Networking at WebKit: WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource
https://bugs.webkit.org/show_bug.cgi?id=221432 <rdar://problem/67069819> Reviewed by John Wilander. We are seeing crashes in ResourceLoadStatisticsDatabaseStore::setPrevalentResource as a result of trying to use a nullopt domainID value. In theory this should never be WTF::nullopt but is because of a failing SQLite query in ResourceLoadStatisticsDatabaseStore::domainID which reports the error "not an error". To fix this we should check the domain ID and return early with a debug assert in setPrevalentResource() if it is WTF::nullopt to avoid a crash. Additionally, we should add more information to the logging statement, specifically the SQLite statement string, to try and debug further. * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: (WebKit::ResourceLoadStatisticsDatabaseStore::domainID const): (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource): Canonical link: https://commits.webkit.org/233742@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent ccae124 commit c40082b

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

Source/WebKit/ChangeLog

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2021-02-05 Kate Cheney <katherine_cheney@apple.com>
2+
3+
CrashTracer: com.apple.WebKit.Networking at WebKit: WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource
4+
https://bugs.webkit.org/show_bug.cgi?id=221432
5+
<rdar://problem/67069819>
6+
7+
Reviewed by John Wilander.
8+
9+
We are seeing crashes in ResourceLoadStatisticsDatabaseStore::setPrevalentResource
10+
as a result of trying to use a nullopt domainID value. In theory this should
11+
never be WTF::nullopt but is because of a failing SQLite query in
12+
ResourceLoadStatisticsDatabaseStore::domainID which reports the error "not an error".
13+
14+
To fix this we should check the domain ID and return early with a
15+
debug assert in setPrevalentResource() if it is WTF::nullopt to avoid
16+
a crash. Additionally, we should add more information to the logging
17+
statement, specifically the SQLite statement string, to try and debug further.
18+
19+
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
20+
(WebKit::ResourceLoadStatisticsDatabaseStore::domainID const):
21+
(WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
22+
123
2021-02-05 Sihui Liu <sihui_liu@appe.com>
224

325
SpeechRecognitionPermissionManager should not handle requests that are already cancelled

Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ Optional<unsigned> ResourceLoadStatisticsDatabaseStore::domainID(const Registrab
796796
auto scopedStatement = this->scopedStatement(m_domainIDFromStringStatement, domainIDFromStringQuery, "domainID"_s);
797797
if (!scopedStatement
798798
|| scopedStatement->bindText(1, domain.string()) != SQLITE_OK) {
799-
RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::domainIDFromString failed, error message: %{private}s", this, m_database.lastErrorMsg());
799+
RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::domainIDFromString failed. Statement: %s. Error message: %{private}s", this, scopedStatement->query().utf8().data(), m_database.lastErrorMsg());
800800
ASSERT_NOT_REACHED();
801801
return WTF::nullopt;
802802
}
@@ -1670,6 +1670,13 @@ void ResourceLoadStatisticsDatabaseStore::setPrevalentResource(const Registrable
16701670
if (shouldSkip(domain))
16711671
return;
16721672

1673+
auto registrableDomainID = domainID(domain);
1674+
if (!registrableDomainID) {
1675+
RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::setPrevalentResource domainID should exist but was not found.", this);
1676+
ASSERT_NOT_REACHED();
1677+
return;
1678+
}
1679+
16731680
auto scopedUpdatePrevalentResourceStatement = this->scopedStatement(m_updatePrevalentResourceStatement, updatePrevalentResourceQuery, "setPrevalentResource"_s);
16741681
if (!scopedUpdatePrevalentResourceStatement
16751682
|| scopedUpdatePrevalentResourceStatement->bindInt(1, 1) != SQLITE_OK
@@ -1693,7 +1700,7 @@ void ResourceLoadStatisticsDatabaseStore::setPrevalentResource(const Registrable
16931700
}
16941701

16951702
StdSet<unsigned> nonPrevalentRedirectionSources;
1696-
recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain(domainID(domain).value(), nonPrevalentRedirectionSources, 0);
1703+
recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain(*registrableDomainID, nonPrevalentRedirectionSources, 0);
16971704
setDomainsAsPrevalent(WTFMove(nonPrevalentRedirectionSources));
16981705
}
16991706

0 commit comments

Comments
 (0)