PacketTunnelProvider crashing immediately when profiling memory leaks?

I'm trying to profile memory leaks in my PacketTunnelProvider, however when I try to do this the profiler immidiately crashes.


My process is as follows:


  1. In XCode, go to Product->Profile
  2. Wait for Instruments to launch
  3. Select "Memory Leaks" from the instruments launch screen.
  4. Launch my application on my phone and verify that the PacketTunnelProvider has been initialized.
  5. In Instruments, select my Provider's process.
  6. Click the record button


When I do this, the Provider's process immidiately crashes.


Below is the crash important pieces of the crash log:


Incident Identifier: 52385F44-7415-46BB-9B2D-81D7E95A8DAF
CrashReporter Key:   36ba17b72c93e0740152f3fd33ca4799c2227c51
Hardware Model:      iPhone8,1
Process:             NAFTVPNProvider [1654]
Path:                /private/var/containers/Bundle/Application/E1705D53-980B-4010-91FD-EB480071BE6B/NAFT.app/PlugIns/NAFTVPNProvider.appex/NAFTVPNProvider
Identifier:          com.NAFT.vpn.provider
Version:             1504224015 (2017.8.31)
Code Type:           ARM-64 (Native)
Role:                Unspecified
Parent Process:      launchd [1]
Coalition:           com.NAFT.vpn.provider [714]




Date/Time:           2017-09-04 10:40:26.5823 -0700
Launch Time:         2017-09-04 10:40:18.5327 -0700
OS Version:          iPhone OS 11.0 (15A5370a)
Baseband Version:    4.00.01
Report Version:      104


Exception Type:  EXC_BAD_ACCESS (SIGKILL - CODESIGNING)
Exception Subtype: unknown at 0x00000001035cfd84
VM Region Info: 0x1035cfd84 is in 0x1035cc000-0x1035d0000;  bytes after start: 15748  bytes before end: 635
      REGION TYPE                      START - END             [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      MALLOC_LARGE           00000001035c8000-00000001035cc000 [   16K] rw-/rwx SM=PRV
--->  Performance tool data  00000001035cc000-00000001035d0000 [   16K] r-x/r-x SM=PRV
      Performance tool data  00000001035d0000-00000001035d4000 [   16K] rw-/rwx SM=PRV


Termination Reason: Namespace CODESIGNING, Code 0x2
Triggered by Thread:  8


Filtered syslog:
None found


. . .


Thread 8 Crashed:
0   ???                             0x00000001035cfd84 0 + 4351393156


Thread 8 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000d03   x1: 0x00000001035d0000   x2: 0x0000000000000005   x3: 0x00000001035d0108
    x4: 0x0000000000000000   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x0000000000000000  x10: 0x0000000000000000  x11: 0x0000000000000000
   x12: 0x0000000000000000  x13: 0x0000000000000000  x14: 0x0000000000000000  x15: 0x0000000000000000
   x16: 0x0000000000000000  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x0000000000000000  x21: 0x0000000000000000  x22: 0x0000000000000000  x23: 0x0000000000000000
   x24: 0x0000000000000000  x25: 0x0000000000000000  x26: 0x0000000000000000  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x0000000000000000   lr: 0x0000000000000000
    sp: 0x00000001035d7f80   pc: 0x00000001035cfd84 cpsr: 0x00000000


I ommitted some of the other thread's back traces as they contained some sensitive data. However, the back trace for the thread that crashed doesn't give a lot of info (at least not to me).

Accepted Reply

I found that if I follow the following process, I can get the profiler to not crash my provider.


  1. In XCode, go to Product->Profile
  2. Wait for Instruments to launch
  3. Select "Memory Leaks" from the instruments launch screen.
  4. Launch my application on my phone and verify that the PacketTunnelProvider has been initialized.
  5. In XCode, go to "Debug->Attatch To Process" and find my Provider's process (IMPORTANT)
  6. In Instruments, select my Provider's process.
  7. Click the record button

Replies

Just some more information. I've tested this on iOS 11 Beta 9 (15A5370a) using XCode Beta 9 (9M214v) as well as tested it with iOS 10.3.3 (14G60) using XCode 8.3.3 (8E3004b) and I go the same result in both test cases.

I found that if I follow the following process, I can get the profiler to not crash my provider.


  1. In XCode, go to Product->Profile
  2. Wait for Instruments to launch
  3. Select "Memory Leaks" from the instruments launch screen.
  4. Launch my application on my phone and verify that the PacketTunnelProvider has been initialized.
  5. In XCode, go to "Debug->Attatch To Process" and find my Provider's process (IMPORTANT)
  6. In Instruments, select my Provider's process.
  7. Click the record button