Bug 223982

Summary: ASSERT(m_sendPort) in IPC::Connection::open() when running some iOS unit tests
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, bfulgham, darin, ggaren, kkinnunen, pvollan, 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=224004
Attachments:
Description Flags
Patch none

Description Chris Dumez 2021-03-30 20:43:53 PDT
ASSERT(m_sendPort) in IPC::Connection::open() when running some iOS unit tests:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.JavaScriptCore      	0x0000000436b18d4e WTFCrash + 14
1   com.apple.WebKit              	0x00000004204333bb WTFCrashWithInfo(int, char const*, char const*, int) + 27
2   com.apple.WebKit              	0x0000000420dbb6ac IPC::Connection::open() + 556
3   com.apple.WebKit              	0x0000000420470870 WebKit::AuxiliaryProcess::initialize(WebKit::AuxiliaryProcessInitializationParameters const&) + 464
4   com.apple.WebKit              	0x0000000421a6289a void WebKit::initializeAuxiliaryProcess<WebKit::WebProcess>(WebKit::AuxiliaryProcessInitializationParameters&&) + 42
5   com.apple.WebKit              	0x0000000421a59921 void WebKit::XPCServiceInitializer<WebKit::WebProcess, WebKit::XPCServiceInitializerDelegate>(WTF::OSObjectPtr<NSObject<OS_xpc_object>*>, NSObject<OS_xpc_object>*, NSObject<OS_xpc_object>*) + 1089
6   com.apple.WebKit              	0x0000000421a594a8 WebContentServiceInitializer + 88
7   com.apple.WebKit              	0x0000000421061355 WebKit::XPCServiceEventHandler(NSObject<OS_xpc_object>*)::'block-literal'::$_1::operator()() const + 85
8   com.apple.WebKit              	0x00000004210612b9 WTF::Detail::CallableWrapper<WebKit::XPCServiceEventHandler(NSObject<OS_xpc_object>*)::'block-literal'::$_1, void>::call() + 25
9   com.apple.JavaScriptCore      	0x0000000436b404a2 WTF::Function<void ()>::operator()() const + 130
10  com.apple.JavaScriptCore      	0x0000000436c470ad WTF::BlockPtr<void ()> WTF::BlockPtr<void ()>::fromCallable<WTF::Function<void ()> >(WTF::Function<void ()>)::'lambda'(void*)::operator()(void*) const + 29
11  com.apple.JavaScriptCore      	0x0000000436c47085 WTF::BlockPtr<void ()> WTF::BlockPtr<void ()>::fromCallable<WTF::Function<void ()> >(WTF::Function<void ()>)::'lambda'(void*)::__invoke(void*) + 21
12  libdispatch.dylib             	0x000000041180c88e _dispatch_client_callout + 8
13  libdispatch.dylib             	0x000000041181a564 _dispatch_async_and_wait_invoke + 109
14  libdispatch.dylib             	0x000000041180c88e _dispatch_client_callout + 8
15  libdispatch.dylib             	0x00000004118198bf _dispatch_main_queue_callback_4CF + 1054
16  com.apple.CoreFoundation      	0x0000000410526050 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
17  com.apple.CoreFoundation      	0x000000041052089c __CFRunLoopRun + 2772
18  com.apple.CoreFoundation      	0x000000041051f8e5 CFRunLoopRunSpecific + 567
19  com.apple.Foundation          	0x0000000410e40e90 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 209
20  com.apple.Foundation          	0x0000000410e410ad -[NSRunLoop(NSRunLoop) run] + 76
21  libxpc.dylib                  	0x0000000411b19151 _xpc_objc_main + 440
22  libxpc.dylib                  	0x0000000411b1b0e6 xpc_main + 122
23  com.apple.WebKit              	0x000000042105d801 WebKit::XPCServiceMain(int, char const**) + 449
24  com.apple.WebKit              	0x00000004226b63db WKXPCServiceMain + 27
25  com.apple.WebKit.WebContent   	0x000000010a395d42 main + 34
26  dyld_sim                      	0x0000000410003c54 _dyld_start + 423
27  dyld                          	0x000000011245ea8e dyld::useSimulatorDyld(int, macho_header const*, char const*, int, char const**, char const**, char const**, unsigned long*, unsigned long*) + 2093
28  dyld                          	0x000000011245c168 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 1198
29  dyld                          	0x0000000112456224 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 450
30  dyld                          	0x0000000112456025 _dyld_start + 37
31  ???                           	0x0000000000000001 0 + 1
Comment 1 Chris Dumez 2021-03-30 20:44:06 PDT
<rdar://75974285>
Comment 2 Chris Dumez 2021-03-30 20:50:51 PDT
Created attachment 424732 [details]
Patch
Comment 3 EWS 2021-03-30 22:34:42 PDT
Committed r275268: <https://commits.webkit.org/r275268>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 424732 [details].
Comment 4 Darin Adler 2021-03-31 09:42:10 PDT
Other places that check against MACH_PORT_NULL but not MACH_PORT_DEAD:

    ResourceUsageThread::platformCollectCPUData: ResourceUsageThreadCocoa.mm
    hasMuxCompatibility: GraphicsChecksMac.cpp
    NetscapePluginHostManager::spawnPluginHost: NetscapePluginHostManager.mm
    NetscapePluginHostManager::initializeVendorPort: NetscapePluginHostManager.mm
    NetscapePluginHostProxy::NetscapePluginHostProxy: NetscapePluginHostProxy.mm
    NetscapePluginHostProxy::processRequests: NetscapePluginHostProxy.mm
    XPCServiceInitializerDelegate::getConnectionIdentifier: XPCServiceEntryPoint.mm
    releaseSendRight: MachSendRight.cpp
    MachSendRight::operator bool: MachSendRight.h

Maybe one or more of these should be using MACH_PORT_VALID instead?
Comment 5 Chris Dumez 2021-03-31 09:42:46 PDT
(In reply to Darin Adler from comment #4)
> Other places that check against MACH_PORT_NULL but not MACH_PORT_DEAD:
> 
>     ResourceUsageThread::platformCollectCPUData: ResourceUsageThreadCocoa.mm
>     hasMuxCompatibility: GraphicsChecksMac.cpp
>     NetscapePluginHostManager::spawnPluginHost: NetscapePluginHostManager.mm
>     NetscapePluginHostManager::initializeVendorPort:
> NetscapePluginHostManager.mm
>     NetscapePluginHostProxy::NetscapePluginHostProxy:
> NetscapePluginHostProxy.mm
>     NetscapePluginHostProxy::processRequests: NetscapePluginHostProxy.mm
>     XPCServiceInitializerDelegate::getConnectionIdentifier:
> XPCServiceEntryPoint.mm
>     releaseSendRight: MachSendRight.cpp
>     MachSendRight::operator bool: MachSendRight.h
> 
> Maybe one or more of these should be using MACH_PORT_VALID instead?

I will check and follow-up.