Sysextd Crashing loading Network Extension

Hi


I am facing weird issue, while loading Tranparent App proxy on macOS 10.15.4 (19E287) (Darwin 19.4.0) using OSSystemExtensionRequest, sysextd gets crashed. App receives SystemExtension com.test.client.test-Client.TestMacAppProxy request did fail: Error Domain=OSSystemExtensionErrorDomain Code=1 "(null)" in request: didFailWithError delegate method.


Following logs are generated by sysextd before crash:


default 17:26:10.287333+0530 sysextd attempting to realize extension with identifier com.test.client.test-Client.TestMacAppProxy

default 17:26:10.298649+0530 sysextd Realizing target path: <private>

default 17:26:10.299194+0530 sysextd Bundle class: UncachedBundle

default 17:26:10.322048+0530 sysextd staging extension with identifier com.test.client.test-Client.TestMacAppProxy

default 17:26:10.383045+0530 sysextd Making activation decision for extension with teamID teamID("27W52P9M7Q"), identifier com.test.client.test-Client.TestMacAppProxy

default 17:26:10.383088+0530 sysextd No extension policy -- activation decision is UserOption

default 17:26:10.383116+0530 sysextd validating extension with identifier com.test.client.test-Client.TestMacAppProxy

default 17:26:11.093684+0530 sysextd waiting for external validation of extension with identifier com.test.client.test-Client.TestMacAppProxy

default 17:26:11.094281+0530 nesessionmanager Validating system extension com.test.client.test-Client.TestMacAppProxy

default 17:26:11.094002+0530 sysextd attempting to realize extension with identifier com.test.client.test-Client.TestMacAppProxy

default 17:26:11.109415+0530 sysextd Realizing target path: <private>

default 17:26:11.109797+0530 sysextd Bundle class: UncachedBundle

default 17:26:11.128982+0530 ReportCrash Parsing corpse data for process sysextd [pid 11854]


App Proxy entitlement:


<plist version="1.0">

<plist version="1.0">

<dict>

<key>com.apple.developer.networking.networkextension</key>

<array>

<string>packet-tunnel-provider</string>

<string>app-proxy-provider</string>

<string>content-filter-provider</string>

<string>dns-proxy</string>

</array>

<key>com.apple.security.app-sandbox</key>

<true/>

<key>com.apple.security.application-groups</key>

<array>

<string>$(TeamIdentifierPrefix)com.example.app-group2</string>

</array>

<key>com.apple.security.network.client</key>

<true/>

<key>com.apple.security.network.server</key>

<true/>

<key>com.apple.security.temporary-exception.files.absolute-path.read-write</key>

<array>

<string>/Library/Logs/TestLogs/</string>

</array>

</dict>

</plist>


App proxy info.plist:


<plist version="1.0">

<dict>

<key>CFBundleDevelopmentRegion</key>

<string>$(DEVELOPMENT_LANGUAGE)</string>

<key>CFBundleDisplayName</key>

<string>TestClientMacAppProxy</string>

<key>CFBundleExecutable</key>

<string>$(EXECUTABLE_NAME)</string>

<key>CFBundleIdentifier</key>

<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

<key>CFBundleInfoDictionaryVersion</key>

<string>6.0</string>

<key>CFBundleName</key>

<string>$(PRODUCT_NAME)</string>

<key>CFBundlePackageType</key>

<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>

<key>CFBundleShortVersionString</key>

<string>2.0</string>

<key>CFBundleVersion</key>

<string>2</string>

<key>LSMinimumSystemVersion</key>

<string>$(MACOSX_DEPLOYMENT_TARGET)</string>

<key>NSHumanReadableCopyright</key>

<string>Copyright © 2020 Test, Inc. All rights reserved.</string>

<key>NSSystemExtensionUsageDescription</key>

<string></string>

<key>NetworkExtension</key>

<dict>

<key>NEMachServiceName</key>

<string>$(TeamIdentifierPrefix)com.example.app-group2.MySystemExtension</string>

<key>NEProviderClasses</key>

<dict>

<key>com.apple.networkextension.app-proxy</key>

<string>AppProxyProvider</string>

</dict>

</dict>

</dict>


Crash report:

Process: sysextd [11854]

Path: /System/Library/Frameworks/SystemExtensions.framework/Versions/A/Helpers/sysextd

Identifier: sysextd

Version: 35.100.1

Code Type: X86-64 (Native)

Parent Process: launchd [1]

Responsible: sysextd [11854]

User ID: 0


Date/Time: 2020-05-27 17:26:11.129 +0530

OS Version: Mac OS X 10.15.4 (19E287)

Report Version: 12

Anonymous UUID: 118067B6-A40A-F8BE-457E-DD9A538CD532


Sleep/Wake UUID: 9235D660-727F-41A5-B4EF-D09B3DB093CC


Time Awake Since Boot: 38000 seconds

Time Since Wake: 8300 seconds


System Integrity Protection: disabled


Crashed Thread: 1 Dispatch queue: sysextd.extension_manager


Exception Type: EXC_BAD_INSTRUCTION (SIGILL)

Exception Codes: 0x0000000000000001, 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY


Termination Signal: Illegal instruction: 4

Termination Reason: Namespace SIGNAL, Code 0x4

Terminating Process: exc handler [11854]



Application Specific Information:

dyld3 mode



Thread 0:

0 libsystem_kernel.dylib 0x00007fff70c594da __semwait_signal_nocancel + 10

1 libsystem_c.dylib 0x00007fff70b695e4 nanosleep$NOCANCEL + 185

2 libsystem_c.dylib 0x00007fff70b8cf38 sleep$NOCANCEL + 41

3 libdispatch.dylib 0x00007fff70ac93da _dispatch_queue_cleanup2 + 156

4 libsystem_pthread.dylib 0x00007fff70d15054 _pthread_tsd_cleanup + 551

5 libsystem_pthread.dylib 0x00007fff70d17512 _pthread_exit + 70

6 libsystem_pthread.dylib 0x00007fff70d14e08 pthread_exit + 42

7 libdispatch.dylib 0x00007fff70ac4fce dispatch_main + 99

8 sysextd 0x0000000102bef860 0x102be7000 + 34912

9 sysextd 0x0000000102bef099 0x102be7000 + 32921

10 libdyld.dylib 0x00007fff70b12cc9 start + 1



Thread 1 Crashed:: Dispatch queue: sysextd.extension_manager

0 sysextd 0x0000000102c2d29e 0x102be7000 + 287390

1 sysextd 0x0000000102c187ab 0x102be7000 + 202667

2 sysextd 0x0000000102c10a0a 0x102be7000 + 170506

3 sysextd 0x0000000102c1802f 0x102be7000 + 200751

4 sysextd 0x0000000102c18098 0x102be7000 + 200856

5 com.apple.Foundation 0x00007fff392de4f3 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S1__ + 10

6 com.apple.Foundation 0x00007fff392689be -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 2363

7 com.apple.Foundation 0x00007fff3921fb29 message_handler + 210

8 libxpc.dylib 0x00007fff70d572bc _xpc_connection_call_event_handler + 56

9 libxpc.dylib 0x00007fff70d561cb _xpc_connection_mach_event + 934

10 libdispatch.dylib 0x00007fff70ab96f8 _dispatch_client_callout4 + 9

11 libdispatch.dylib 0x00007fff70acebc9 _dispatch_mach_msg_invoke + 435

12 libdispatch.dylib 0x00007fff70abeaf6 _dispatch_lane_serial_drain + 263

13 libdispatch.dylib 0x00007fff70acf71c _dispatch_mach_invoke + 481

14 libdispatch.dylib 0x00007fff70abeaf6 _dispatch_lane_serial_drain + 263

15 libdispatch.dylib 0x00007fff70abf5d6 _dispatch_lane_invoke + 363

16 libdispatch.dylib 0x00007fff70ac8c09 _dispatch_workloop_worker_thread + 596

17 libsystem_pthread.dylib 0x00007fff70d13a3d _pthread_wqthread + 290

18 libsystem_pthread.dylib 0x00007fff70d12b77 start_wqthread + 15



Thread 2:

0 libsystem_kernel.dylib 0x00007fff70c59502 __sigsuspend_nocancel + 10

1 libdispatch.dylib 0x00007fff70ac949a _dispatch_sigsuspend + 36

2 libdispatch.dylib 0x00007fff70ac9476 _dispatch_sig_thread + 53



Thread 3:

0 libsystem_pthread.dylib 0x00007fff70d12b68 start_wqthread + 0



Thread 1 crashed with X86 Thread State (64-bit):

rax: 0x000070000f899d70 rbx: 0x000070000f899d70 rcx: 0x0000000000000000 rdx: 0x0000000000000001

rdi: 0x000070000f899d70 rsi: 0xffffffff00000001 rbp: 0x000070000f899e10 rsp: 0x000070000f899d60

r8: 0x0000000000000000 r9: 0x0000000000000ae0 r10: 0x00007fff8edbfc40 r11: 0xfffff00a26891d78

r12: 0x00007ff5e9007f70 r13: 0x000070000f899d70 r14: 0x00007fff89d68098 r15: 0x00007fff89d7f430

rip: 0x0000000102c2d29e rfl: 0x0000000000010202 cr2: 0x00007fff975d10e8


Logical CPU: 6

Error Code: 0x00000000

Trap Number: 6


Binary Images:

0x102be7000 - 0x102c65fff sysextd (35.100.1) <8A4A86EE-EEAC-34BF-80C3-5DCD8D71E102> /System/Library/Frameworks/SystemExtensions.framework/Versions/A/Helpers/sysextd

0x102ef9000 - 0x102f0fff7 com.apple.security.csparser (3.0 - 59306.101.1) <EEE7ED0C-8625-3A9A-A1FB-F118800AB125> /System/Library/Frameworks/Security.framework/Versions/A/PlugIns/csparser.bundle/Contents/MacOS/csparser

0x103039000 - 0x1030caeff dyld (750.5) <1F893B81-89A5-3502-8510-95B97B9F730D> /usr/lib/dyld


External Modification Summary:

Calls made by other processes targeting this process:

task_for_pid: 1

thread_create: 0

thread_set_state: 0

Calls made by this process:

task_for_pid: 0

thread_create: 0

thread_set_state: 0

Calls made by all processes on this machine:

task_for_pid: 11251599

thread_create: 0

thread_set_state: 2721


VM Region Summary:

ReadOnly portion of Libraries: Total=513.8M resident=0K(0%) swapped_out_or_unallocated=513.8M(100%)

Writable regions: Total=100.7M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=100.7M(100%)


VIRTUAL REGION

REGION TYPE SIZE COUNT (non-coalesced)

=========== ======= =======

Activity Tracing 256K 1

Dispatch continuations 16.0M 1

Kernel Alloc Once 8K 1

MALLOC 74.7M 38

MALLOC guard page 16K 4

STACK GUARD 56.0M 4

Stack 9752K 4

VM_ALLOCATE 8K 2

__DATA 13.6M 221

__DATA_CONST 268K 14

__FONT_DATA 4K 1

__LINKEDIT 388.1M 4

__OBJC_RO 32.2M 1

__OBJC_RW 1888K 1

__TEXT 125.7M 222

__UNICODE 564K 1

mapped file 27.2M 3

shared memory 580K 8

=========== ======= =======

TOTAL 746.7M 531


Please note I removed loaded dylibs to reduce the crash report size.

Replies

Please note I removed loaded dylibs to reduce the crash report size.

Unfortunately those dylibs are necessary for me to do anything useful with your crash report )-:

Still,

sysextd
should not crash regardless of what you’re doing within your sysex. Please file a bug about that. Make sure to attach the crash report and a sysdiagnose log (per the instructions on our Bug Reporting > Profiles and Logs page). If you can also attach the code necessary to trigger the crash, that’d be grand.

Once you’re done, post your bug number here and I’ll take another look.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Eskimo


I filed bug ( FB7717328) with relevent info and my code. Please let me know if I should give more info.


Regards,

Anand Choubey

Thanks for filing that bug. Using the info there I was able to symbolicate the backtrace of the crash threading within

sysextd
:
0 specialized OSSystemExtensionProperties.init(from:) + 494
1 SystemExtensionsAPIFrameworkClient.resolveActivationConflict(newExt:existing:) + 331
2 specialized ExtensionManager.activateExtension(identifier:client:) + 810
3 SystemExtensionsAPIFrameworkClient.activateExtension(withIdentifer:) + 351
4 @objc SystemExtensionsAPIFrameworkClient.activateExtension(withIdentifer:) + 72
5 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S1__ + 10

Frame 0 is crashing because it tripped over an internal assert. It’s not clear how that came about, although looking at the backtrace it seems that the you are in the process of activating your extension (frame 3) and there’s some sort of activation conflict (frame 1).

Honestly, I’m not sure what to make of this. Have you tried this on a fresh machine? Does it still crash there? [I typically use VMs for this sort of testing, so getting back a fresh machine is easy.]

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks Eskimo


Two Network extension enablment flows were triggered at same time that leads to the crash. Now I fixed it.


Regards,

Anand Choubey