iOS 14 CoreFoundation crash with EXC_BREAKPOINT

Hi,
I am facing a strange issue in my app with iOS14 there is a intermittent crash, i am using NetServiceBrowser for MDNS discovery not sure if that is causing the problem crash log has below information:

Crashed: com.apple.main-thread
0 CoreFoundation 0x1a906c4c4 CFAssertMismatchedTypeID + 108
1 CoreFoundation 0x1a8f7db0c
CFRunLoopSourceRemoveFromRunLoop + 298
2 CFNetwork 0x1a96255b0 CFNetServiceBrowserStopSearch + 460
3 CoreFoundation 0x1a8f81240 CFRUNLOOP
ISCALLINGOUTTOASOURCE0PERFORMFUNCTION + 24
4 CoreFoundation 0x1a8f81140
CFRunLoopDoSource0 + 204
5 CoreFoundation 0x1a8f80488
CFRunLoopDoSources0 + 256
6 CoreFoundation 0x1a8f7aa40
CFRunLoopRun + 776
7 CoreFoundation 0x1a8f7a200 CFRunLoopRunSpecific + 572
8 GraphicsServices 0x1bf075598 GSEventRunModal + 160
9 UIKitCore 0x1ab840004 -[UIApplication
run] + 1052
10 UIKitCore 0x1ab8455d8 UIApplicationMain + 164
Answered by DTS Engineer in 787317022

Yes. using Multipeer Connectivity

OK. In that case my answer is that you should stop using Multipeer Connectivity. This is a long-standing bug and, while I can’t predict the future with 100% accuracy, I think it’s reasonable to infer future behaviour from past behaviour. In this case, you’re looking at a crashing bug that’s been around for at least 3 years old [1]. How long are you prepared to wait for a fix?

IMO Multipeer Connectivity should be officially deprecated in favour of Network framework [2]. If you’d like to make that transition:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Based on the age of this thread. I suspect that this bug has been around for much longer than that.

[2] And, to be clear, this is a personal opinion. I don’t set official Apple policy for this stuff. The official policy is in TN3151 Choosing the right networking API, which has to walk a fine line because Multipeer Connectivity isn’t officially deprecated.

We've been seeing a number of crashes with a similar assertion, but
related to the EAAccessory Framework.

These errors are unlikely to be related. You’re crashing for the same reason (CF has detected a type mismatch at runtime) but the cause of that type mismatch is very different.

Consider this snippet from the crashing thread’s backtrace:

Code Block
1 CoreFoundation … _CFAssertMismatchedTypeID + 100
2 CoreFoundation … CFRunLoopSourceSignal + 312
3 ExternalAccessory … -[EAInputStream _scheduleCallback] + 72
4 ExternalAccessory … -[EAInputStream _performAtEndOfStreamValidation] + 116


Frame 1 is the type mismatch, but note how frames 2 is different (in the other cases it was removing a run loop source) as are frames 3 and 4.

I recommend that you open a new thread for this and tag it with ExternalAccessory to see if anyone with EA experience (which I do not have, btw) chimes in.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Hello there,

Has anyone figured out the cause of this crash?
We are facing the same issue since iOS 14 (14.3 and 14.4) when using multipeer connectivity and MCNearbyServiceBrowser.

Thanks!

Our app uses Multipeer Connectivity and we've been experiencing this issue since iOS 14 was released.

One common theme is that the app is running in the background when the issue arrises and we get the crash.

Expected typeID 46 (CFRunLoopSource) does not match actual typeID 61 (CFSocket)

We've been trying to diagnose what is happening through our remote logging, but so far the cause of the issue has escaped us.

One common theme is that the app is running in the background when the
issue arrises and we get the crash.

You use Multipeer Connectivity in the background? Is that just because you don’t shut it down when you move to the background? Or because you actually need to use it in the background?

Multipeer Connectivity isn’t rated for use the background. Some parts of it will likely work as long as you guarantee that your process never gets suspended (as is generally true for out networking APIs). Other parts simply don’t make sense in the background.

Having said that, it shouldn’t crash )-:

Do you have an Apple crash report for this? If so, please post it here. Use the text attachment feature (the paperclip icon) to avoid clogging up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Hi,

Would this Apple crash report help?

Thanks,


Would this Apple crash report help?

Yes, and no.

It’s clearly the same issue and it helped me track down the bug we’re using to track this (r. 60399638). However, that bug doesn’t offer any suggestions for how you might work around it.

Two factoids of note:
  • We’re seeing this reported by a number of different apps, suggesting that this is a bug in the system rather than a bug in the apps.

  • It’s likely that immediate cause of this crash was a change we made in iOS 14 to harden CF-level APIs against type mismatches (r. 14049993). So, this problem may have been occurring previously but iOS 14 is now detecting it reliably.

Oh, one other thing: It’s clear that this bug is triggered by a CF-level problem. That means it affects CFNetServiceBrowser and all the things layered on top of that, including NSNetServiceBrowser and Multipeer Connectivity. If you move to a different Bonjour API, one not based on CFNetServiceBrowser, it’s likely that you wouldn’t see this problem. That includes NWBrowser and the very low-level DNS-SD API (<dns_sd.h>). Of those, I’m going to recommend NWBrowser; Network framework is the future of (non-HTTP) networking on our platforms.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

So has this bug been fixed?

Our current thinking is that the bug mentioned above (r. 60399638) is specific to Multipeer Connectivity. Are you using that API? Or some other Bonjour API?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is there any update to the status of this bug (r. 60399638)?

No.

Are there any workarounds

As I said in my previous post, our current thinking is that this is specific to Multipeer Connectivity, and thus the ‘obvious’ workaround is to use a different API for your networking. My general recommendation is Network framework but if you want to talk specifics I encourage you to start a new thread with details about your network architecture.

an estimated timeline for a fix?

I can’t predict the future, alas. I will, however, note this problem started in iOS 14 and hasn’t been fixed in iOS 15, and let you draw your own conclusions.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

We are facing a similar, intermittent crash, observed in iPad Pro (12.9-inch, 3rd generation) Version:17.2.0 real devices

Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0xf2564 (Missing UUID 47e4ec098f6e30a899d034024d4f8122) 1 libobjc.A.dylib 0x19eb4 (Missing UUID 9bab95567a2a30a8acde010ba8e2367d) 2 Foundation 0x82940 (Missing UUID 9558b1ebdda33fda88a5e785ecdfcd30) 3 Foundation 0xe0ee0 (Missing UUID 9558b1ebdda33fda88a5e785ecdfcd30) 4 Foundation 0x75af30 (Missing UUID 9558b1ebdda33fda88a5e785ecdfcd30) 5 AppKit 0x7cbf8 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 6 AppKit 0xad154c (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 7 AppKit 0x31e5b4 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 8 AppKit 0x33e1c0 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 9 AppKit 0xde1a74 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 10 AppKit 0x347e4 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 11 AppKit 0xde159c (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 12 AppKit 0xde0f54 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 13 AppKit 0xde112c (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 14 AppKit 0x7a695c (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 15 AppKit 0x7a6ce4 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 16 SkyLight 0xb134 (Missing UUID 67c718b452dc3b258e7a12ea2b414369) 17 SkyLight 0x3a0230 (Missing UUID 67c718b452dc3b258e7a12ea2b414369) 18 SkyLight 0x3a012c (Missing UUID 67c718b452dc3b258e7a12ea2b414369) 19 libdispatch.dylib 0x1cb8 (Missing UUID a53d555df748301083fe385c660a81bd) 20 libdispatch.dylib 0x3910 (Missing UUID a53d555df748301083fe385c660a81bd) 21 libdispatch.dylib 0x11fa8 (Missing UUID a53d555df748301083fe385c660a81bd) 22 libdispatch.dylib 0x11bc0 (Missing UUID a53d555df748301083fe385c660a81bd) 23 CoreFoundation 0xbeecc (Missing UUID 47e4ec098f6e30a899d034024d4f8122) 24 CoreFoundation 0x7c7d0 (Missing UUID 47e4ec098f6e30a899d034024d4f8122) 25 CoreFoundation 0x7b9ac (Missing UUID 47e4ec098f6e30a899d034024d4f8122) 26 HIToolbox 0x30448 (Missing UUID e2187dfe1fb43b47874ea0a6291e51b2) 27 HIToolbox 0x30284 (Missing UUID e2187dfe1fb43b47874ea0a6291e51b2) 28 HIToolbox 0x2ffdc (Missing UUID e2187dfe1fb43b47874ea0a6291e51b2) 29 AppKit 0x398a4 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 30 AppKit 0x813980 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 31 AppKit 0x2cd50 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 32 AppKit 0x4014 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 33 AppKit 0x2573a4 (Missing UUID f3527312e4263f7cb77b2bf49d1b7c04) 34 UIKitMacHelper 0x46a8 (Missing UUID f03f3f95a13739e2b894c76dc6e8a1e5) 35 UIKitCore 0x3cfc (Missing UUID 2aebcc42a1aa3535be531da03d4d2ce3) 36 Enlighten 0x70e8 main + 32 (main.m:32) 37 ??? 0x183ef50e0 (Missing)

Any updates on this crash / fix / rdar? We are also seeing this crash. Even when the app is in foreground. It happens randomly. Hard to reproduce.

Are you using Multipeer Connectivity?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

For details , see my attached crash log

The interesting part is in 2 CFNetwork 0x00000001895e6c58 _BrowserCancel(__CFNetServiceBrowser*) + 120 (CFNetServiceBrowser.c:179)

which can be opened here: https://opensource.apple.com/source/CFNetwork/CFNetwork-129.18/NetServices/CFNetServiceBrowser.c.auto.html


/* static */ void
_BrowserCancel(__CFNetServiceBrowser* browser) {
	
	CFNetServiceBrowserClientCallBack cb = NULL;
	CFStreamError error;
	void* info = NULL;
	
	// Retain here to guarantee safety really after the browser release,
	// but definitely before the callback.
	CFRetain(browser);
	
	// Lock the browser
	__CFSpinLock(&browser->_lock);
	
	// If the browse canceled, don't need to do any of this.
	if (browser->_trigger) {
		
		// Save the callback if there is one at this time.
		cb = browser->_callback;
		
		// Save the error and client information for the callback
		memmove(&error, &(browser->_error), sizeof(error));
		info = browser->_client.info;
		
		// Remove the trigger from run loops and modes
		_CFTypeUnscheduleFromMultipleRunLoops(browser->_trigger, browser->_schedules);
		
		// Invalidate the run loop source that got here
		CFRunLoopSourceInvalidate((CFRunLoopSourceRef)(browser->_trigger));
		
		// Release the trigger now.
		CFRelease(browser->_trigger);
		browser->_trigger = NULL;
	}

	// Unlock the browser so the callback can be made safely.
	__CFSpinUnlock(&browser->_lock);
	
	// If there is a callback, inform the client of the finish.
	if (cb)
		cb((CFNetServiceBrowserRef)browser, 0, NULL, &error, info);
	
	// Go ahead and release now that the callback is done.
	CFRelease(browser);
}

the CFRunLoopSourceInvalidate causes the crash? There is a lock. But might be not correct?

Yes. using Multipeer Connectivity

OK. In that case my answer is that you should stop using Multipeer Connectivity. This is a long-standing bug and, while I can’t predict the future with 100% accuracy, I think it’s reasonable to infer future behaviour from past behaviour. In this case, you’re looking at a crashing bug that’s been around for at least 3 years old [1]. How long are you prepared to wait for a fix?

IMO Multipeer Connectivity should be officially deprecated in favour of Network framework [2]. If you’d like to make that transition:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Based on the age of this thread. I suspect that this bug has been around for much longer than that.

[2] And, to be clear, this is a personal opinion. I don’t set official Apple policy for this stuff. The official policy is in TN3151 Choosing the right networking API, which has to walk a fine line because Multipeer Connectivity isn’t officially deprecated.

Network framework is also compatible with Nearby Interaction and background?

I’m not particularly au fait with NI, but as a general rule Network framework can do anything that Multipeer Connectivity can do (and more). It’s really a question of focus. Multipeer Connectivity expects you to use the network in a specific way, and provides a high-level API based on that. Network framework is very generic. That means that in some cases you have to do a little more work to achieve a specific goal with Network framework than with Multipeer Connectivity. But, on the upside:

  • It’s more reliable.

  • It lets you design on-the-wire architecture that matches your problem domain.

If you have questions about how to achieve a specific goal, I recommend that you put them in a new thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

iOS 14 CoreFoundation crash with EXC_BREAKPOINT
 
 
Q