Bug 233219 - [ Monterey Debug arm64 ] ASSERTION FAILED: result == &worker ./workers/service/server/SWServer.cpp(837) : void WebCore::SWServer::workerContextTerminated(WebCore::SWServerWorker &)
Summary: [ Monterey Debug arm64 ] ASSERTION FAILED: result == &worker ./workers/servic...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-16 15:38 PST by Robert Jenner
Modified: 2022-01-05 18:30 PST (History)
6 users (show)

See Also:


Attachments
Patch (2.46 KB, patch)
2022-01-05 13:58 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (2.45 KB, patch)
2022-01-05 15:11 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Jenner 2021-11-16 15:38:34 PST
TestWebKitAPI.ServiceWorkers.RestoreFromDiskNonDefaultStore is flaky hitting an assertion on Monterey Debug arm64. 


HISTORY:
https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.ServiceWorkers.RestoreFromDiskNonDefaultStore

TestWebKitAPI.ServiceWorkers.RestoreFromDiskNonDefaultStore
        ASSERTION FAILED: result == &worker
        ./workers/service/server/SWServer.cpp(837) : void WebCore::SWServer::workerContextTerminated(WebCore::SWServerWorker &)
        1   0x13c49ce3c WTFCrash
        2   0x107db4810 WTF::NeverDestroyed<WTF::String, WTF::AnyThreadsAccessTraits>::operator WTF::String const&() const
        3   0x10c8987c8 WebCore::SWServer::workerContextTerminated(WebCore::SWServerWorker&)
        4   0x10c92d25c WebCore::SWServerWorker::contextTerminated()
        5   0x10c92d1c0 WebCore::SWServerToContextConnection::workerTerminated(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>)
        6   0x12c3657b0 void IPC::callMemberFunctionImpl<WebKit::WebSWServerToContextConnection, void (WebCore::SWServerToContextConnection::*)(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>), std::__1::tuple<WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType> >, 0ul>(WebKit::WebSWServerToContextConnection*, void (WebCore::SWServerToContextConnection::*)(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>), std::__1::tuple<WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType> >&&, std::__1::integer_sequence<unsigned long, 0ul>)
        7   0x12c3655ec void IPC::callMemberFunction<WebKit::WebSWServerToContextConnection, void (WebCore::SWServerToContextConnection::*)(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>), std::__1::tuple<WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType> >, std::__1::integer_sequence<unsigned long, 0ul> >(std::__1::tuple<WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType> >&&, WebKit::WebSWServerToContextConnection*, void (WebCore::SWServerToContextConnection::*)(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>))
        8   0x12c3611cc void IPC::handleMessage<Messages::WebSWServerToContextConnection::WorkerTerminated, WebKit::WebSWServerToContextConnection, void (WebCore::SWServerToContextConnection::*)(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>)>(IPC::Connection&, IPC::Decoder&, WebKit::WebSWServerToContextConnection*, void (WebCore::SWServerToContextConnection::*)(WTF::ObjectIdentifier<WebCore::ServiceWorkerIdentifierType>))
        9   0x12c3609cc WebKit::WebSWServerToContextConnection::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
        10  0x12a8e2324 WebKit::NetworkConnectionToWebProcess::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
        11  0x129bdbdf8 IPC::Connection::dispatchMessage(IPC::Decoder&)
        12  0x129bdc4c0 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)
        13  0x129bdca90 IPC::Connection::dispatchOneIncomingMessage()
        14  0x129bfc9cc IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_12::operator()()
        15  0x129bfc8dc WTF::Detail::CallableWrapper<IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_12, void>::call()
        16  0x13c4c4dc0 WTF::Function<void ()>::operator()() const
        17  0x13c549a9c WTF::RunLoop::performWork()
        18  0x13c54e3e0 WTF::RunLoop::performWork(void*)
        19  0x1b1c70bbc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
        20  0x1b1c70b08 __CFRunLoopDoSource0
        21  0x1b1c707f4 __CFRunLoopDoSources0
        22  0x1b1c6f168 __CFRunLoopRun
        23  0x1b1c6e694 CFRunLoopRunSpecific
        24  0x1b2b47e10 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
        25  0x1b2bd7f50 -[NSRunLoop(NSRunLoop) run]
        26  0x1b1902900 _xpc_objc_main
        27  0x1b1902204 xpc_main
        28  0x12aa1580c WebKit::XPCServiceMain(int, char const**)
        29  0x12c380898 WKXPCServiceMain
        30  0x1045d3eb0 main
        31  0x10482d0f4
        ASSERTION FAILED: databaseUpdated
        /Volumes/Data/worker/monterey-debug/build/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm(77) : void WebKit::WebPage::platformDidReceiveLoadParameters(const WebKit::LoadParameters &)
        1   0x13ad58e3c WTFCrash
        2   0x128501680 JSC::JSValue::JSValue()
        3   0x129e841e0 WebKit::WebPage::platformDidReceiveLoadParameters(WebKit::LoadParameters const&)
        4   0x12a830460 WebKit::WebPage::loadRequest(WebKit::LoadParameters&&)
        5   0x12a90311c void IPC::callMemberFunctionImpl<WebKit::WebPage, void (WebKit::WebPage::*)(WebKit::LoadParameters&&), std::__1::tuple<WebKit::LoadParameters>, 0ul>(WebKit::WebPage*, void (WebKit::WebPage::*)(WebKit::LoadParameters&&), std::__1::tuple<WebKit::LoadParameters>&&, std::__1::integer_sequence<unsigned long, 0ul>)
        6   0x12a902198 void IPC::callMemberFunction<WebKit::WebPage, void (WebKit::WebPage::*)(WebKit::LoadParameters&&), std::__1::tuple<WebKit::LoadParameters>, std::__1::integer_sequence<unsigned long, 0ul> >(std::__1::tuple<WebKit::LoadParameters>&&, WebKit::WebPage*, void (WebKit::WebPage::*)(WebKit::LoadParameters&&))
        7   0x12a8add44 void IPC::handleMessage<Messages::WebPage::LoadRequest, WebKit::WebPage, void (WebKit::WebPage::*)(WebKit::LoadParameters&&)>(IPC::Connection&, IPC::Decoder&, WebKit::WebPage*, void (WebKit::WebPage::*)(WebKit::LoadParameters&&))
        8   0x12a8a71e0 WebKit::WebPage::didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&)
        9   0x12a83f7b0 WebKit::WebPage::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
        10  0x1289aae40 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&)
        11  0x12a0d79a4 WebKit::WebProcess::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
        12  0x128497df8 IPC::Connection::dispatchMessage(IPC::Decoder&)
        13  0x1284984c0 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)
        14  0x128498a90 IPC::Connection::dispatchOneIncomingMessage()
        15  0x1284b89cc IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_12::operator()()
        16  0x1284b88dc WTF::Detail::CallableWrapper<IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_12, void>::call()
        17  0x13ad80dc0 WTF::Function<void ()>::operator()() const
        18  0x13ae05a9c WTF::RunLoop::performWork()
        19  0x13ae0a3e0 WTF::RunLoop::performWork(void*)
        20  0x1b1c70bbc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
        21  0x1b1c70b08 __CFRunLoopDoSource0
        22  0x1b1c707f4 __CFRunLoopDoSources0
        23  0x1b1c6f168 __CFRunLoopRun
        24  0x1b1c6e694 CFRunLoopRunSpecific
        25  0x1b2b47e10 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
        26  0x1b2bd7f50 -[NSRunLoop(NSRunLoop) run]
        27  0x1b1902900 _xpc_objc_main
        28  0x1b1902204 xpc_main
        29  0x1292d180c WebKit::XPCServiceMain(int, char const**)
        30  0x12ac3c898 WKXPCServiceMain
        31  0x102cd7eb0 main
Comment 1 Radar WebKit Bug Importer 2021-11-16 15:39:49 PST
<rdar://problem/85478756>
Comment 2 Robert Jenner 2021-11-16 15:40:45 PST
It appears to have started very shortly after we released Monterey, and started testing it on OpenSource.
Comment 3 Robert Jenner 2021-11-16 16:07:17 PST
I was able to reproduce the assertion on my Apple Silicon Mac at Monterey Debug ToT using the following test:

run-api-tests --root /Volumes/Data/Builds/StarBravo/Debug/debugbuild282629  TestWebKitAPI.ServiceWorkers.RestoreFromDiskNonDefaultStore --iterations 100
Comment 4 Chris Dumez 2022-01-05 13:06:35 PST
(In reply to Robert Jenner from comment #3)
> I was able to reproduce the assertion on my Apple Silicon Mac at Monterey
> Debug ToT using the following test:
> 
> run-api-tests --root /Volumes/Data/Builds/StarBravo/Debug/debugbuild282629 
> TestWebKitAPI.ServiceWorkers.RestoreFromDiskNonDefaultStore --iterations 100

Those repro steps also worked on my Intel machine. Investigating.
Comment 5 Chris Dumez 2022-01-05 13:16:23 PST
SWServer::workerContextTerminated() gets called twice for the same worker. As a result, the second time around, we get a null worker from the HashMap.
Comment 6 Chris Dumez 2022-01-05 13:23:43 PST
(In reply to Chris Dumez from comment #5)
> SWServer::workerContextTerminated() gets called twice for the same worker.
> As a result, the second time around, we get a null worker from the HashMap.

The first call is from SWServer::markAllWorkersForRegistrableDomainAsTerminated(), the second from SWServerWorker::contextTerminated().
Comment 7 Chris Dumez 2022-01-05 13:58:39 PST
Created attachment 448427 [details]
Patch
Comment 8 Darin Adler 2022-01-05 15:10:11 PST
Comment on attachment 448427 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=448427&action=review

> Source/WebCore/ChangeLog:13
> +        we would retrieve a null worker from the HashMap and it the assertion. I updated the call to ignore

"hit the assertion"
Comment 9 Chris Dumez 2022-01-05 15:11:59 PST
Created attachment 448435 [details]
Patch
Comment 10 EWS 2022-01-05 18:30:08 PST
Committed r287667 (245764@main): <https://commits.webkit.org/245764@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 448435 [details].