Crash in com.apple.CFNetwork.CustomProtocols

I have written a custom protocol, which is a subclass of `URLProtocol` but somehow i got a crash with following info:


EXC_BAD_ACCESS

com.apple.CFNetwork.CustomProtocols (15)#0 0x0000000183fbad8c in URLConnectionInstanceData::withWorkQueueAsync(void () block_pointer) const ()

#1 0x0000000183fcc3f8 in URLConnectionLoader_Classic::protocolDidReceiveResponse(_CFURLResponse*) ()

#2 0x0000000183e6b4b0 in -[__NSCFURLProtocolClient_NS withCustomProtocolScheduling:] ()

#3 0x0000000183e6bb98 in -[__NSCFURLProtocolClient_NS URLProtocol:didReceiveResponse:cacheStoragePolicy:] ()

#4 0x00000001056f3f34 in SecureURLProtocol.gotProgressCall(request:force:) ()

#5 0x00000001056f489c in SecureURLProtocol.requestFinishedLoading(request:) ()

#6 0x00000001056f2de8 in SecureURLProtocol.startLoading() ()

#7 0x00000001056f30d8 in @objc SecureURLProtocol.startLoading() ()

#8 0x0000000183e716f4 in ___ZN16CFURLProtocol_NS28_protocolInterface_startLoadEPK20_CFCachedURLResponse_block_invoke ()

#9 0x000000010652545c in _dispatch_client_callout ()

#10 0x0000000106531b74 in _dispatch_block_invoke_direct ()

#11 0x0000000184091f94 in RunloopBlockContext::_invoke_block(void const*, void*) ()

#12 0x00000001837a7900 in CFArrayApplyFunction ()

#13 0x0000000184091e58 in RunloopBlockContext::perform() ()

#14 0x00000001840931d8 in MultiplexerSource::perform() ()

#15 0x0000000184092f38 in MultiplexerSource::_perform(void*) ()

#16 0x000000018388a2e8 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()

#17 0x000000018388a268 in __CFRunLoopDoSource0 ()

#18 0x0000000183889af0 in __CFRunLoopDoSources0 ()

#19 0x00000001838876c8 in __CFRunLoopRun ()

#20 0x00000001837a7fb8 in CFRunLoopRunSpecific ()

#21 0x00000001840913b8 in _privateRunloopEmulationSet(void*) ()

#22 0x000000018350c31c in _pthread_body ()

#23 0x000000018350c1e8 in _pthread_start ()

#24 0x000000018350ac28 in thread_start ()


Does anyone know what could be the source of this issue?


Thanks

There are many ways to go wrong with a custom

URLProtocol
subclass. First up, I recommend that you look at the read me for the CustomHTTPProtocol sample code, which has a summary of the rules you’re expected to follow.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Crash in com.apple.CFNetwork.CustomProtocols
 
 
Q