IPC not working after stopping tunnel provider

I faced with strange case. When I send error from my packet tunnel provider using completion handler, I can't send new IPC messages. Here is some info from log:


Feb 15 18:44:11 iPad nesessionmanager[443] <Notice>: NESMVPNSession[]: Received a start command from MyApp[3179]
Feb 15 18:44:11 iPad nesessionmanager[443] <Notice>: NESMVPNSession[]: status changed to connecting

// now I call completion handler with error

Feb 15 18:44:12 iPad nesessionmanager[443] <Notice>: NESMVPNSession[]: status changed to disconnecting
Feb 15 18:44:12 iPad nesessionmanager[443] <Error>: SIOCGIFMTU failed: Device not configured
Feb 15 18:44:12 iPad nesessionmanager[443] <Error>: NEVirtualInterfaceAdjustReadBufferSize: interface_get_mtu failed (6), defaulting to max mtu
Feb 15 18:44:12 iPad nesessionmanager[443] <Error>: SIOCGIFMTU failed: Device not configured
Feb 15 18:44:12 iPad nesessionmanager[443] <Error>: NEVirtualInterfaceAdjustReadBufferSize: interface_get_mtu failed (6), defaulting to max mtu


Feb 15 18:44:12 iPad neagent[444] <Warning>: plugin .PacketTunnel invalidated
Feb 15 18:44:12 iPad nesessionmanager[443] <Notice>: NESMVPNSession[]: status changed to disconnected, last stop reason Stop command received


Feb 15 18:44:12 iPad PacketTunnel[3181] <Warning>: host connection <NSXPCConnection: 0x14688400> connection from pid 444 invalidated


Feb 15 18:44:12 iPad configd[30] <Notice>: network changed
Feb 15 18:44:12 iPad symptomsd[98] <Error>: nw_interface_create_with_name netutil_ifname_to_ifindex(utun0) failed, dumping backtrace:
         [armv7f] libnetcore-583.20.10
     0   libsystem_network.dylib             0x24a2018b __nw_create_backtrace_string + 130
     1   libsystem_network.dylib             0x24a39359 nw_interface_create_with_name + 132
     2   Network                             0x2dcff41d <redacted> + 88
     3   SymptomEvaluator                    0x367b60e1 config_callback + 824
     4   SystemConfiguration                 0x25107ef1 <redacted> + 172
     5   SystemConfiguration                 0x25108207 <redacted> + 42
     6   libdispatch.dylib                   0x248a9b5b <redacted> + 10
     7   libdispatch.dylib                   0x248b675b <redacted> + 1758
     8   libdispatch.dylib                   0x248b5d99 <redacted> + 284
     9   libdispatch.dylib                   0x248b8495 <redacted> + 396
     10  libdispatch.dylib                   0x248b8305 <redacted> + 96
     11  libsystem_pthread.dylib             0x24a67b29 _pthread_wqthread + 1024
     12  libsystem_pthread.dylib             0x24a67718 start_wqthread + 8
Feb 15 18:44:12 iPad symptomsd[98] <Error>: -[NWInterface initWithInterfaceName:] nw_interface_create_with_name(utun0) failed, dumping backtrace:
         [armv7f] libnetcore-583.20.10
     0   libsystem_network.dylib             0x24a2018b __nw_create_backtrace_string + 130
     1   Network                             0x2dcff471 <redacted> + 172
     2   SymptomEvaluator                    0x367b60e1 config_callback + 824
     3   SystemConfiguration                 0x25107ef1 <redacted> + 172
     4   SystemConfiguration                 0x25108207 <redacted> + 42
     5   libdispatch.dylib                   0x248a9b5b <redacted> + 10
     6   libdispatch.dylib                   0x248b675b <redacted> + 1758
     7   libdispatch.dylib                   0x248b5d99 <redacted> + 284
     8   libdispatch.dylib                   0x248b8495 <redacted> + 396
     9   libdispatch.dylib                   0x248b8305 <redacted> + 96
     10  libsystem_pthread.dylib             0x24a67b29 _pthread_wqthread + 1024
     11  libsystem_pthread.dylib             0x24a67718 start_wqthread + 8


After that I can't send any IPC message with sendProviderMessage: from my UI application. It just send message but never receive callback.

I guess this is because packet tunnel provider process was terminated, but there was no notification about that termination in UI application. Also in another case I see that iOS restarted packet tunnel provider process and everything works fine.


Device: iPad MC773LL/A with iOS 9.2.1 (13D15)

Any chance to have answer here please?

I had similar crashes because of missing type conversions in my (Swift) code. Look out for mismatches between Int, Int64 and Int32. In my case I was comparing an Int64 to an Int -- it worked on newer (64bit) devices and crashed on older (32bit) devices. Strangely enough neither Xcode nor the compiler did complain. The problem was in no way related to networking, and the stack trace was completely misleading.

IPC not working after stopping tunnel provider
 
 
Q