Accessing a NWListener shortly after starting and with "Local Network" denied, causes "_os_unfair_lock_corruption_abort" Crash

This works fine when the local network permissions are allowed but not when the permission is denied.

Simply trying to print or set the newConnectionHandler to nil on the listener will result in a crash.

Does anyone know why this happens?

Crash:
Code Block
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001e6cd3234
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [50016]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libsystem_platform.dylib 0x00000001e6cd3234 _os_unfair_lock_corruption_abort + 36 (lock.c:524)
1 libsystem_platform.dylib 0x00000001e6cd1164 _os_unfair_lock_lock_slow + 320 (lock.c:575)
2 libnetwork.dylib 0x00000001a070e02c nw_listener_set_new_connection_handler + 92 (listener.m:128)
3 (setting newConnectionHandler to nil)


Note that we have already added NSLocalNetworkUsageDescription and a NSBonjourServices tcp

We see that we are unable to check the status of the Local Network permissions but maybe there is another way to mitigate getting the crash when trying to clear out our listener.

Simply trying to print or set the newConnectionHandler to nil on
the listener will result in a crash.

This is a known bug (r. 67681125). I believe it’s fixed in the current 14.2b2. Can you retest there?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I have encountered a similar crash.
  1. I start listening for UDP packages with Local Network access enabled. Everything works as expected.

  2. I kill the app and disable the Local Network access.

  3. I open the app again and as soon as I try to re-create the NWListener the app crashes and I get the following message:

[listener] nwlistenerdns_handler [L1] advertising denied by policy


Is there a way to check for Local Network access?

Is there a way to check for Local Network access?

Not directly. See FAQ-9 of the Local Network Privacy FAQ.

Have you tested this on the latest 14.2 beta?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
On "14.2" Beta the app doesn't crash anymore. Thank you.
Accessing a NWListener shortly after starting and with "Local Network" denied, causes "_os_unfair_lock_corruption_abort" Crash
 
 
Q