Branch: refs/heads/webkitglib/2.52
  Home:   https://github.com/WebKit/WebKit
  Commit: bb319fa215dedc52c05b180905e466ad97938c76
      
https://github.com/WebKit/WebKit/commit/bb319fa215dedc52c05b180905e466ad97938c76
  Author: David Kilzer <[email protected]>
  Date:   2026-02-03 (Tue, 03 Feb 2026)

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

  Log Message:
  -----------
  Cherry-pick 306672@main (215b7246a621). 
https://bugs.webkit.org/show_bug.cgi?id=306673

    [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

Canonical link: https://commits.webkit.org/305877.40@webkitglib/2.52



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

Reply via email to