Crashes with associateToEnterpriseNetwork with null values for SSID

FB12755685

Sent a feedback through feedback assistant and wanted to elaborate more over here.

Our application configures and connects to wireless networks using CoreWLAN. We started seeing crashes while connecting with the latest Beta versions of Sonoma. The crashes showed EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) which led me to believe it might be a CPU architecture issue due to the mention of i386 but that was completely wrong.

Turns out the error is due to:

*** CFRetain() called with NULL ***

CFRetain.cold.1

[CWInterface associateToEnterpriseNetwork:identity:username:password:error:] + 127

Sample code to consistently reproduce the crash on Sonoma

CWInterface* interface = [CWInterface interfaceWithName:@“en0”];
NSError *scanError = nil;
NSSet* testNetworks = [interface scanForNetworksWithName:@“SSIDName” error:&testScanError];
CWNetwork* network = [testNetworks anyObject];
NSError* connectionError = nil;

BOOL connected = [interface associateToEnterpriseNetwork:network identity:identityRef username:nil password:nil error:&connectionError]; //<--crash here

The associateToEnterpriseNetwork function expects a CWNetwork object. In the Beta versions of macOS Sonoma, the CWNetwork object has (null) values in the ssid field. This causes a cold CFRetain runtime error when trying to associate to the network. If we can detect a broadcasting "SSIDName" SSID and try to associate to it, we will always crash on the last line.

The reason for the crash seems to be due to a difference in how the CWNetwork objects are handled in Sonoma.

Sonoma:

<CWNetwork: 0x6000036cb590> [ssid=(null), bssid=(null), security=WPA2 Enterprise, rssi=-53, channel=<CWChannel: 0x6000036fce90> [channelNumber=1(2GHz), channelWidth={20MHz}], ibss=0]

Ventura:

<CWNetwork: 0x6000010ffa60> [ssid=Chris640, bssid=(null), security=WPA2 Enterprise, rssi=-45, channel=<CWChannel: 0x6000010ffca0> [channelNumber=1(2GHz), channelWidth={20MHz}], ibss=0]

Is my assumption that the crash is due to the (null) in the SSID field correct?

FB12755685

Thanks for filing that.

but that was completely wrong.

Indeed. On Intel CPUs we use ud2 as our trap instruction, which means your program crashes with SIGILL rather than the more normal SIGTRAP.

I’d like to see a crash report for this issue. Please reproduce the problem on your Mac, trigger a sysdiagnose, add that to your bug report, and then post back here when you’re done.

Share and Enjoy

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

Attached the sysdiagnose and crash report files to the bug report

Thanks for that.

Earlier you wrote:

Is my assumption that the crash is due to the (null) in the SSID field correct?

I think so, yes. AFAICT it’s not actually the ssid property that’s causing the problem, but rather than ssidData property, but those are effectively the same thing.

I think you’re hitting this crash because of new privacy restriction on macOS 14 beta. See this post.

Still, it shouldn’t crash, and I appreciate you filing a bug about that.

Share and Enjoy

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

@pyro_90 I am going through same issue, can you please help how did you resolve your issue? Even though I am able to get latitude and longitude info, still SSID info is null.

Crashes with associateToEnterpriseNetwork with null values for SSID
 
 
Q