[webkit-changes] [WebKit/WebKit] b73bcf: Fix some potential debug assertions in WebCoreNSUR...

Alex Christensen noreply at github.com
Tue Dec 19 08:54:57 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b73bcfa4b339b6caa674cf8f449ff34a1c739467
      https://github.com/WebKit/WebKit/commit/b73bcfa4b339b6caa674cf8f449ff34a1c739467
  Author: Alex Christensen <achristensen at apple.com>
  Date:   2023-12-19 (Tue, 19 Dec 2023)

  Changed paths:
    M Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h
    M Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm

  Log Message:
  -----------
  Fix some potential debug assertions in WebCoreNSURLSession
https://bugs.webkit.org/show_bug.cgi?id=266618
rdar://115087609

Reviewed by Chris Dumez.

cancel and suspend can be called on any thread.  If they are called on a background thread
and the task finishes between when the selector is called on the background thread and the
callOnMainThread lambda is called, then things can get into a bad state and we can hit the
debug assertion in taskCompleted: indicating that a task was not in the set.  To fix this,
I add some state checks in cancel and suspend.  Because _state can be written to from a
background thread in cancel, I made the ivar std::atomic.  I add WTF_GUARDED_BY_LOCK to
prevent future issues around use of _dataTasks and ASSERT(isMainThread()); around use of
_origins to verify its thread safety.

* Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h:
* Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession task:addSecurityOrigin:]):
(-[WebCoreNSURLSession isCrossOrigin:]):
(-[WebCoreNSURLSessionDataTask initWithSession:identifier:request:]):
(-[WebCoreNSURLSessionDataTask state]):
(-[WebCoreNSURLSessionDataTask cancel]):
(-[WebCoreNSURLSessionDataTask suspend]):
(-[WebCoreNSURLSessionDataTask resume]):
(-[WebCoreNSURLSessionDataTask _resource:loadFinishedWithError:metrics:]):

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




More information about the webkit-changes mailing list