Bug 218856

Summary: ASSERTION FAILED: isValidIdentifier(m_identifier) seen with TestWebKitAPI.GPUProcess.WebProcessTerminationAfterTooManyGPUProcessCrashes
Product: WebKit Reporter: Ryan Haddad <ryanhaddad>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, darin, eric.carlson, ews-watchlist, ggaren, glenn, jer.noble, peng.liu6, philipj, sergio, thorton, webkit-bot-watchers-bugzilla, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=218811
Attachments:
Description Flags
Patch
none
Patch none

Description Ryan Haddad 2020-11-12 10:13:31 PST
TestWebKitAPI.GPUProcess.WebProcessTerminationAfterTooManyGPUProcessCrashes
        ASSERTION FAILED: isValidIdentifier(m_identifier)
        /Volumes/Data/slave/catalina-debug/build/WebKitBuild/Debug/usr/local/include/wtf/ObjectIdentifier.h(69) : void WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType>::encode(Encoder &) const [T = WebKit::RemoteAudioDestinationIdentifierType, Encoder = IPC::Encoder]
        1   0x7cf3830c9 WTFCrash
        2   0x7a000322b WTFCrashWithInfo(int, char const*, char const*, int)
        3   0x7a07e1742 void WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType>::encode<IPC::Encoder>(IPC::Encoder&) const
        4   0x7a07e16bd IPC::ArgumentCoder<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> >::encode(IPC::Encoder&, WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&)
        5   0x7a07e1680 void IPC::Encoder::encode<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, (void*)0>(WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&)
        6   0x7a07c262d IPC::Encoder& IPC::Encoder::operator<<<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, (void*)0>(WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&)
        7   0x7a17ce470 IPC::TupleEncoder<4ul, WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, WebKit::SharedMemory::IPCHandle const&, WebCore::CAAudioStreamDescription const&, unsigned long long>::encode(IPC::Encoder&, std::__1::tuple<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, WebKit::SharedMemory::IPCHandle const&, WebCore::CAAudioStreamDescription const&, unsigned long long> const&)
        8   0x7a17ce41d IPC::ArgumentCoder<std::__1::tuple<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, WebKit::SharedMemory::IPCHandle const&, WebCore::CAAudioStreamDescription const&, unsigned long long> >::encode(IPC::Encoder&, std::__1::tuple<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, WebKit::SharedMemory::IPCHandle const&, WebCore::CAAudioStreamDescription const&, unsigned long long> const&)
        9   0x7a17ce3e0 void IPC::Encoder::encode<std::__1::tuple<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, WebKit::SharedMemory::IPCHandle const&, WebCore::CAAudioStreamDescription const&, unsigned long long> const&, (void*)0>(std::__1::tuple<WTF::ObjectIdentifier<WebKit::RemoteAudioDestinationIdentifierType> const&, WebKit::SharedMemory::IPCHandle const&, WebCore::CAAudioStreamDescription const&, unsigned long long> const&)
        10  0x7a17873cb bool IPC::Connection::send<Messages::RemoteAudioDestinationManager::AudioSamplesStorageChanged>(Messages::RemoteAudioDestinationManager::AudioSamplesStorageChanged&&, unsigned long long, WTF::OptionSet<IPC::SendOption>)
        11  0x7a1787326 WebKit::RemoteAudioDestinationProxy::storageChanged(WebKit::SharedMemory*)
        12  0x7a0f5d31a WebKit::SharedRingBufferStorage::setStorage(WTF::RefPtr<WebKit::SharedMemory, WTF::RawPtrTraits<WebKit::SharedMemory>, WTF::DefaultRefDerefTraits<WebKit::SharedMemory> >&&)
        13  0x7a0f5d448 WebKit::SharedRingBufferStorage::deallocate()
        14  0x7b2826375 WebCore::CARingBuffer::deallocate()
        15  0x7b28265bf WebCore::CARingBuffer::allocate(WebCore::CAAudioStreamDescription const&, unsigned long)
        16  0x7a1785d5f WebKit::RemoteAudioDestinationProxy::connectToGPUProcess()
        17  0x7a17874c7 WebKit::RemoteAudioDestinationProxy::gpuProcessConnectionDidClose(WebKit::GPUProcessConnection&)
        18  0x7a175d53e WebKit::GPUProcessConnection::didClose(IPC::Connection&)
        19  0x7a0098077 IPC::Connection::connectionDidClose()::$_7::operator()()
        20  0x7a0097f6e WTF::Detail::CallableWrapper<IPC::Connection::connectionDidClose()::$_7, void>::call()
        21  0x7cf3ae562 WTF::Function<void ()>::operator()() const
        22  0x7cf42df05 WTF::RunLoop::performWork()
        23  0x7cf432591 WTF::RunLoop::performWork(void*)
        24  0x7fff387bad52 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
        25  0x7fff387bacf1 __CFRunLoopDoSource0
        26  0x7fff387bab0b __CFRunLoopDoSources0
        27  0x7fff387b983a __CFRunLoopRun
        28  0x7fff387b8e3e CFRunLoopRunSpecific
        29  0x7fff3ae541c8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
        30  0x7fff3af06c6f -[NSRunLoop(NSRunLoop) run]
        31  0x7fff72a734ea _xpc_objc_main.cold.4
        LEAK: 1 WebProcessPool
        LEAK: 1 WebPageProxy
        
        /Volumes/Data/slave/catalina-debug/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:158
        Expected equality of these values:
          webViewPID
            Which is: 53596
          [webView _webProcessIdentifier]
            Which is: 53602


https://build.webkit.org/builders/Apple-Catalina-Debug-WK2-Tests/builds/7712/steps/run-api-tests/logs/stdio
Comment 1 Radar WebKit Bug Importer 2020-11-12 10:13:45 PST
<rdar://problem/71331809>
Comment 2 Ryan Haddad 2020-11-12 10:19:23 PST
The test has been crashing on Catalina and iOS debug bots since it was added in https://trac.webkit.org/changeset/269703/webkit

https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.GPUProcess.WebProcessTerminationAfterTooManyGPUProcessCrashes
Comment 3 Chris Dumez 2020-11-12 10:59:57 PST
Will investigate shortly.
Comment 4 Chris Dumez 2020-11-12 11:44:06 PST
(In reply to Chris Dumez from comment #3)
> Will investigate shortly.

It does not reproduce on my macOS Debug build. Will try an IOS Debug build.
Comment 5 Chris Dumez 2020-11-12 11:45:06 PST
From the crash, it is likely RemoteAudioDestinationProxy::m_destinationID is not a valid identifier. m_destinationID is supposed to get initialized in RemoteAudioDestinationProxy::connectToGPUProcess(), which gets called in the RemoteAudioDestinationProxy constructor though.
Comment 6 Chris Dumez 2020-11-12 11:54:29 PST
(In reply to Chris Dumez from comment #5)
> From the crash, it is likely RemoteAudioDestinationProxy::m_destinationID is
> not a valid identifier. m_destinationID is supposed to get initialized in
> RemoteAudioDestinationProxy::connectToGPUProcess(), which gets called in the
> RemoteAudioDestinationProxy constructor though.

Ok, I can reproduce with iOS Debug simulator. This should make this a lot easier to figure out.
Comment 7 Chris Dumez 2020-11-12 12:47:06 PST
Created attachment 413967 [details]
Patch
Comment 8 Peng Liu 2020-11-12 13:26:08 PST
Comment on attachment 413967 [details]
Patch

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

> Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:88
>      connection.connection().addThreadMessageReceiver(Messages::RemoteAudioDestinationProxy::messageReceiverName(), this, destinationID.toUInt64());

Just curious, should we do this if `didSucceed` is false?
Comment 9 Chris Dumez 2020-11-12 13:27:37 PST
Comment on attachment 413967 [details]
Patch

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

>> Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:88
>>      connection.connection().addThreadMessageReceiver(Messages::RemoteAudioDestinationProxy::messageReceiverName(), this, destinationID.toUInt64());
> 
> Just curious, should we do this if `didSucceed` is false?

You're right. it is probably better not to since destinationID is 0. It does not hurt but it does not make sense to register with a bad ID.
Comment 10 Chris Dumez 2020-11-12 13:28:58 PST
Created attachment 413972 [details]
Patch
Comment 11 EWS 2020-11-12 14:01:40 PST
Committed r269749: <https://trac.webkit.org/changeset/269749>

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