Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 215b7246a62175d42d803158283bc89cbfd87e3a
      
https://github.com/WebKit/WebKit/commit/215b7246a62175d42d803158283bc89cbfd87e3a
  Author: David Kilzer <[email protected]>
  Date:   2026-02-02 (Mon, 02 Feb 2026)

  Changed paths:
    M Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp

  Log Message:
  -----------
  [ITP] Crash in 
ResourceLoadStatisticsStore::ensureResourceStatisticsForRegistrableDomain due 
to unsafe std::optional access
<https://bugs.webkit.org/show_bug.cgi?id=306673>
<rdar://problem/167532652>

Reviewed by Matthew Finkel.

ResourceLoadStatisticsStore::ensureResourceStatisticsForRegistrableDomain()
crashes with std::bad_optional_access when calling .value() on an empty
std::optional<unsigned> returned by domainID(domain).  The crash occurs
when insertObservedDomain() successfully inserts a domain into the
database, but domainID(domain) immediately fails to find the
just-inserted domain, returning std::nullopt.

The fix replaces the unsafe .value() call with proper std::optional
checking and error recovery.  This prevents process termination and
provides diagnostic logging to help identify the underlying database
consistency issue.

Includes a drive-by fix to
ResourceLoadStatisticsStore::insertObservedDomain() to correct a
misleading error message that said "failed to find domain" when the
domain was actually found and already exists.

Unable to write a test since it would require removing a just-inserted
domain from the database caused by an unknown mechanism external to
ensureResourceStatisticsForRegistrableDomain().

* Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::insertObservedDomain):
- Fix error message.
(WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForRegistrableDomain):
- Fix crash by checking for value in std::optional before use.

Canonical link: https://commits.webkit.org/306672@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to