Why is NEPacketTunnelProvider receiving stopTunnelWithReason NEProviderStopReasonInternalError

We're seeing some new and odd behavior where our NEPacketTunnelProvider instance is receiving a stopTunnelWithReason:completionHandler: call with reason NEProviderStopReasonInternalError.

Can anyone shed some light into how to diagnose this situation?

Here are some basic details:

  • Our PacketTunnel has been in use for years and we only started seeing this issue recently.

  • We're able to reproduce this behavior with some light browsing.

  • The documentation provides no insight on why/when this might occur. Can anyone shed some light into how to diagnose this situation?

Things we’ve tried so far:

  1. We grabbed a sysdiagnose and looked through the logs:

    a. Right before the stopTunnel, we see log items referring to a "nesessionmanager" (PID 2038) getting killed. Presumably, this is due to hitting a highwater threshold. (See sysdiagnose items listing below)

    b. Thinking these were due to memory pressure, we added logging of available/used memory.

    c. We confirmed that the PacketTunnel was only using 11,808.73 KB.

    d. Since, there is plenty of memory available the PacketTunnel was not killed for using too much memeory.

  2. We wondered if this could be due to our UI's usage of objects like: NETunnelProviderManager and NETunnelProviderSession

    a. We ran an experiment where we swiped closed the UI to ensure these manager/session objects are not used.

    b. Without the UI, we still saw the random stopTunnel with NEProviderStopReasonInternalError.

  3. We wondered if our routes were the problem, but they seem correct.

    a. See the NEPacketTunnelNetworkSettings listing below

LISTING: From the system_logs.logarchive, the nesessionmanager log items:

2025-01-23 15:07:59.176146 -0800 0x278 memorystatus com.apple.xnu memorystatus: killing process 2038 [nesessionmanager] in high band ? (140) - memorystatus_available_pages: 18932 default kernel
2025-01-23 15:07:59.179641 -0800 0x278 memorystatus com.apple.xnu memorystatus: killing_highwater_process pid 2038 [nesessionmanager] (highwater 140) 7056KB - memorystatus_available_pages: 19161 compressor_size:69593 default kernel
2025-01-23 15:07:59.179888 -0800 0x278 memorystatus com.apple.xnu memorystatus: failed to kill a process and no memory was reclaimed default kernel
2025-01-23 15:07:59.185695 -0800 1 0x45e0c user/501/com.apple.nesessionmanager [2038] exited with exit reason (namespace: 1 code: 0x2) - JETSAM_REASON_MEMORY_HIGHWATER, ran for 266329ms default launchd
2025-01-23 15:07:59.231188 -0800 31 0x45bf2 com.apple.networkextension nesessionmanager(2038) exited default UserEventAgent
2025-01-23 15:07:59.253371 -0800 31 0x45bf2 com.apple.networkextension nesessionmanager exited with active sessions, re-launching nesessionmanager to clear agent status default UserEventAgent

LISTING: From the system_logs.logarchive, the stopTunnel from PID 2046

2025-01-23 15:07:59.201581 -0800 SamplePacketTunnel [Extension com.REDACTED.PacketTunnel]: Calling stopTunnelWithReason because: None
2025-01-23 15:08:20.783112 -0800 SamplePacketTunnel 2025-01-23 15:08:20,786 2046 ERROR REDACTED (285805) - Exiting after waiting for stopTunnelWithReason

LISTING: routes from NEPacketTunnelNetworkSettings

{
tunnelRemoteAddress = fd12:3456:789a:1::1
DNSSettings = {
protocol = cleartext
server = (
2606:4700:4700::1234,
2606:4700:4700::2345,
)
matchDomains = (
,
)
matchDomainsNoSearch = NO
}
IPv6Settings = {
configMethod = manual
addresses = (
fd12:3456:789a:1::1,
)
networkPrefixLengths = (
64,
)
includedRoutes = (
{
destinationAddress = 2606:4700:4700::2345
destinationNetworkPrefixLength = 128
},
{
destinationAddress = 2606:4700:4700::1234
destinationNetworkPrefixLength = 128
},
)
excludedRoutes = (
{
destinationAddress = REDACTED
destinationNetworkPrefixLength = 128
},
{
destinationAddress = REDACTED
destinationNetworkPrefixLength = 128
},
)
}
MTU = 3072
}

Thanks for taking a look, any help or suggestions would be greatly appreciated

Answered by DTS Engineer in 822849022
Written by msepulveda in 822790022
By "new", I meant a new version of iOS [like] 18.2.1.

OK.

Written by msepulveda in 822790022
We submitted this as item FB16402318

Yeah, that’s the best path forward here.

If you have any info about the first OS release with this problem, please add it to your bug.

Share and Enjoy

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

This is iOS, right?

Written by msepulveda in 773186021
We're seeing some new and odd behavior

Please clarify what you mean by “new”. Is this correlated with a new version of your app? Or with a new version of iOS?

Share and Enjoy

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

Hi Quinn,

By "new", I meant a new version of iOS. We are seeing this behavior with the newest iOS version 18.2.1

We submitted this as item FB16402318 with the feedback assistant.

We attached 2 sysdiagnoses archives to our feedback. For the second sysdiagnose, we used the VPN (Network Extension) for iOS/iPadOS profile found at the Profile and Logs page

Thanks!

Written by msepulveda in 822790022
By "new", I meant a new version of iOS [like] 18.2.1.

OK.

Written by msepulveda in 822790022
We submitted this as item FB16402318

Yeah, that’s the best path forward here.

If you have any info about the first OS release with this problem, please add it to your bug.

Share and Enjoy

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

Why is NEPacketTunnelProvider receiving stopTunnelWithReason NEProviderStopReasonInternalError
 
 
Q