xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 514 forks source link

Unhandled Null Exception in CFData #18551

Open Tobi-Tobi opened 1 year ago

Tobi-Tobi commented 1 year ago

Steps to Reproduce

  1. Sadly, I don't know. Users are reporting that they open up the app after some time of inactivity and then it crashes.

I do have crash reports:

Crash report one.log

Here is the crash report from the AppCenter, yet again that probably got less information:

``` Incident Identifier: 7e76a6ed-851b-47da-be0e-f45f22992d38 CrashReporter Key: DA7F2F3B-5B88-485A-8545-8330F002F4FE Hardware Model: iPhone12,1 Process: My.App.iOS [63739] Path: /private/var/containers/Bundle/Application/136B6E12-1A81-412B-AA35-E6FA2D74724A/My.App.iOS.app/My.App.iOS Identifier: com.my.app Version: 4.2.2 (57803) Code Type: arm64 Parent Process: [1] Date/Time: 2023-07-09T10:00:30.999Z Launch Time: 2023-07-08T19:14:54Z OS Version: iPhone OS 16.5 (20F66) Report Version: 104 Exception Type: SIGABRT Exception Codes: #0 at 0x1dc5e2558 Crashed Thread: 0 Application Specific Information: *** Terminating app due to uncaught exception 'SIGABRT', reason: 'Value cannot be null. Parameter name: native' Xamarin Exception Stack: System.ArgumentNullException: Value cannot be null. Parameter name: native at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.copy_from_unmanaged_fixed(intptr,int,System.Array,int,void*) at System.Runtime.InteropServices.Marshal.copy_from_unmanaged (System.IntPtr source, System.Int32 startIndex, System.Array destination, System.Int32 length) <0x10361a3e0 + 0x00047> in :0 at System.Runtime.InteropServices.Marshal.Copy (System.IntPtr source, System.Byte[] destination, System.Int32 startIndex, System.Int32 length) <0x10361a444 + 0x00087> in :0 at CoreFoundation.CFData.GetBuffer () <0x103f71784 + 0x0006b> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0 at CoreFoundation.CFSocket.OnCallback (System.IntPtr s, System.nuint type, System.IntPtr address, System.IntPtr data, System.IntPtr info) <0x103f725d8 + 0x0011b> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0 at (wrapper native-to-managed) CoreFoundation.CFSocket.OnCallback(intptr,System.nuint,intptr,intptr,intptr) at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&) at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) <0x103f82330 + 0x0004b> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0 at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) <0x103f82410 + 0x000f3> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0 at My.App.iOS.IosApplication.Main (System.String[] args) <0x10307a218 + 0x00033> in :0 at null.null at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&) at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) <0x103f82330 + 0x0004b> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0 at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) <0x103f82410 + 0x000f3> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0 at My.App.iOS.IosApplication.Main (System.String[] args) <0x10307a218 + 0x00033> in :0 Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001dc5e2558 __pthread_kill + 8 1 libsystem_c.dylib 0x00000001a4b9f178 abort + 176 2 My.App.iOS 0x0000000108017408 0x102eb0000 + 85357576 3 My.App.iOS 0x0000000107eddd18 0x102eb0000 + 84073752 4 My.App.iOS 0x0000000107e72e10 0x102eb0000 + 83635728 5 My.App.iOS 0x0000000107e717e4 0x102eb0000 + 83630052 6 My.App.iOS 0x0000000107e674dc 0x102eb0000 + 83588316 7 My.App.iOS 0x000000010348f5cc 0x102eb0000 + 6157772 8 My.App.iOS 0x0000000107f4a598 0x102eb0000 + 84518296 9 My.App.iOS 0x0000000108017078 0x102eb0000 + 85356664 10 My.App.iOS 0x0000000107e72368 0x102eb0000 + 83633000 11 My.App.iOS 0x0000000107e737e8 0x102eb0000 + 83638248 12 My.App.iOS 0x0000000107e67634 0x102eb0000 + 83588660 13 My.App.iOS 0x0000000103490798 0x102eb0000 + 6162328 14 My.App.iOS 0x0000000103f72858 0x102eb0000 + 17573976 15 My.App.iOS 0x0000000103f0d2b0 0x102eb0000 + 17158832 16 CoreFoundation 0x000000019d7864e4 __CFSocketPerformV0 + 732 17 CoreFoundation 0x000000019d742128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 18 CoreFoundation 0x000000019d74e7b4 __CFRunLoopDoSource0 + 172 19 CoreFoundation 0x000000019d6d35e8 __CFRunLoopDoSources0 + 240 20 CoreFoundation 0x000000019d6e90d4 __CFRunLoopRun + 824 21 CoreFoundation 0x000000019d6ee3ec CFRunLoopRunSpecific + 608 22 GraphicsServices 0x00000001d8bb335c GSEventRunModal + 160 23 UIKitCore 0x000000019fa7b6e8 -[UIApplication _run] + 884 24 UIKitCore 0x000000019fa7b34c UIApplicationMain + 336 25 My.App.iOS 0x000000010800b9a0 0x102eb0000 + 85309856 26 My.App.iOS 0x0000000103efd6fc 0x102eb0000 + 17094396 27 My.App.iOS 0x0000000103f8237c 0x102eb0000 + 17638268 28 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 29 My.App.iOS 0x0000000107f3e820 0x102eb0000 + 84469792 30 My.App.iOS 0x0000000107f44b28 0x102eb0000 + 84495144 31 My.App.iOS 0x0000000107e62ee4 0x102eb0000 + 83570404 32 My.App.iOS 0x000000010801fd64 0x102eb0000 + 85392740 33 My.App.iOS 0x0000000103000df4 0x102eb0000 + 1379828 34 ??? 0x00000001bcbeedec 0x0 + 0 Thread 1: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 2: 0 libsystem_kernel.dylib 0x00000001dc5dc558 __psynch_cvwait + 8 1 My.App.iOS 0x0000000107fe1a48 0x102eb0000 + 85137992 2 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 3 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 3: 0 libsystem_kernel.dylib 0x00000001dc5dbc00 semaphore_wait_trap + 8 1 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 2 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 3 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 4 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 4: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 5: 0 libsystem_kernel.dylib 0x00000001dc5dbc84 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x00000001dc5eee2c mach_msg_overwrite + 536 2 libsystem_kernel.dylib 0x00000001dc5dc1c8 mach_msg + 20 3 CoreFoundation 0x000000019d6e8024 __CFRunLoopServiceMachPort + 156 4 CoreFoundation 0x000000019d6e9250 __CFRunLoopRun + 1204 5 CoreFoundation 0x000000019d6ee3ec CFRunLoopRunSpecific + 608 6 Foundation 0x0000000197976fd4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208 7 Foundation 0x0000000197976ebc -[NSRunLoop(NSRunLoop) runUntilDate:] + 60 8 UIKitCore 0x000000019fbae3fc -[UIEventFetcher threadMain] + 412 9 Foundation 0x0000000197990544 __NSThread__start__ + 712 10 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 11 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 6: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 7: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 8: 0 libsystem_kernel.dylib 0x00000001dc5dc558 __psynch_cvwait + 8 1 My.App.iOS 0x0000000107ff0fc4 0x102eb0000 + 85200836 2 My.App.iOS 0x0000000107ff9d2c 0x102eb0000 + 85237036 3 My.App.iOS 0x0000000107f80524 0x102eb0000 + 84739364 4 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 5 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 6 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 7 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 9: 0 My.App.iOS 0x0000000107e60534 0x102eb0000 + 83559732 1 My.App.iOS 0x0000000107e576b0 0x102eb0000 + 83523248 2 My.App.iOS 0x0000000107e58168 0x102eb0000 + 83525992 3 My.App.iOS 0x0000000107e7fecc 0x102eb0000 + 83689164 4 My.App.iOS 0x0000000107e87410 0x102eb0000 + 83719184 5 My.App.iOS 0x0000000107e86ef4 0x102eb0000 + 83717876 6 My.App.iOS 0x000000010348e95c 0x102eb0000 + 6154588 7 My.App.iOS 0x000000010403fb50 0x102eb0000 + 18414416 8 My.App.iOS 0x00000001036217c4 0x102eb0000 + 7804868 9 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 10 My.App.iOS 0x00000001035c8e24 0x102eb0000 + 7441956 11 My.App.iOS 0x00000001035c7854 0x102eb0000 + 7436372 12 My.App.iOS 0x0000000103755a68 0x102eb0000 + 9067112 13 My.App.iOS 0x000000010392ac14 0x102eb0000 + 10988564 14 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 15 My.App.iOS 0x0000000107f3e820 0x102eb0000 + 84469792 16 My.App.iOS 0x0000000107f4ae08 0x102eb0000 + 84520456 17 My.App.iOS 0x0000000107efd6fc 0x102eb0000 + 84203260 18 My.App.iOS 0x0000000103390708 0x102eb0000 + 5113608 19 My.App.iOS 0x00000001035f3f3c 0x102eb0000 + 7618364 20 My.App.iOS 0x0000000103fb82d4 0x102eb0000 + 17859284 21 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 22 My.App.iOS 0x0000000107f4010c 0x102eb0000 + 84476172 23 My.App.iOS 0x0000000107f83370 0x102eb0000 + 84751216 24 My.App.iOS 0x0000000107f80be4 0x102eb0000 + 84741092 25 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 26 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 27 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 28 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 10: 0 libsystem_kernel.dylib 0x00000001dc5dc558 __psynch_cvwait + 8 1 My.App.iOS 0x0000000107ff0fc4 0x102eb0000 + 85200836 2 My.App.iOS 0x0000000107f97aa0 0x102eb0000 + 84834976 3 My.App.iOS 0x0000000107f97978 0x102eb0000 + 84834680 4 My.App.iOS 0x0000000107f97b9c 0x102eb0000 + 84835228 5 My.App.iOS 0x0000000107f868a4 0x102eb0000 + 84764836 6 My.App.iOS 0x0000000107f02844 0x102eb0000 + 84224068 7 My.App.iOS 0x000000010338d788 0x102eb0000 + 5101448 8 My.App.iOS 0x00000001035bc40c 0x102eb0000 + 7390220 9 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 10 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 11 My.App.iOS 0x0000000107f3e820 0x102eb0000 + 84469792 12 My.App.iOS 0x0000000107f441bc 0x102eb0000 + 84492732 13 My.App.iOS 0x0000000107f8c470 0x102eb0000 + 84788336 14 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 15 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 16 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 11: 0 libsystem_kernel.dylib 0x00000001dc5dc7e8 __select + 8 1 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 2 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 12: 0 libsystem_kernel.dylib 0x00000001dc5dbc84 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x00000001dc5eee2c mach_msg_overwrite + 536 2 libsystem_kernel.dylib 0x00000001dc5dc1c8 mach_msg + 20 3 CoreFoundation 0x000000019d6e8024 __CFRunLoopServiceMachPort + 156 4 CoreFoundation 0x000000019d6e9250 __CFRunLoopRun + 1204 5 CoreFoundation 0x000000019d6ee3ec CFRunLoopRunSpecific + 608 6 CFNetwork 0x000000019e8d9580 _CFURLStorageSessionDisableCache + 60896 7 Foundation 0x0000000197990544 __NSThread__start__ + 712 8 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 9 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 13: 0 libsystem_kernel.dylib 0x00000001dc5dc558 __psynch_cvwait + 8 1 My.App.iOS 0x0000000107ff0fec 0x102eb0000 + 85200876 2 My.App.iOS 0x0000000107f97aa0 0x102eb0000 + 84834976 3 My.App.iOS 0x0000000107f97978 0x102eb0000 + 84834680 4 My.App.iOS 0x0000000107f313c4 0x102eb0000 + 84415428 5 My.App.iOS 0x0000000107f00e28 0x102eb0000 + 84217384 6 My.App.iOS 0x000000010338bd78 0x102eb0000 + 5094776 7 My.App.iOS 0x00000001035b60d0 0x102eb0000 + 7364816 8 My.App.iOS 0x00000001035acce4 0x102eb0000 + 7326948 9 My.App.iOS 0x000000010349014c 0x102eb0000 + 6160716 10 My.App.iOS 0x000000010497954c 0x102eb0000 + 28087628 11 My.App.iOS 0x00000001035b664c 0x102eb0000 + 7366220 12 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 13 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 14 My.App.iOS 0x0000000107f3e820 0x102eb0000 + 84469792 15 My.App.iOS 0x0000000107f441bc 0x102eb0000 + 84492732 16 My.App.iOS 0x0000000107f8c470 0x102eb0000 + 84788336 17 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 18 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 19 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 14: 0 libsystem_kernel.dylib 0x00000001dc5dc558 __psynch_cvwait + 8 1 My.App.iOS 0x0000000107ff0fec 0x102eb0000 + 85200876 2 My.App.iOS 0x0000000107f97aa0 0x102eb0000 + 84834976 3 My.App.iOS 0x0000000107f97978 0x102eb0000 + 84834680 4 My.App.iOS 0x0000000107f313c4 0x102eb0000 + 84415428 5 My.App.iOS 0x0000000107f00e28 0x102eb0000 + 84217384 6 My.App.iOS 0x000000010338bd78 0x102eb0000 + 5094776 7 My.App.iOS 0x00000001035b60d0 0x102eb0000 + 7364816 8 My.App.iOS 0x00000001035acce4 0x102eb0000 + 7326948 9 My.App.iOS 0x000000010349014c 0x102eb0000 + 6160716 10 My.App.iOS 0x000000010497954c 0x102eb0000 + 28087628 11 My.App.iOS 0x00000001035b664c 0x102eb0000 + 7366220 12 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 13 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 14 My.App.iOS 0x0000000107f3e820 0x102eb0000 + 84469792 15 My.App.iOS 0x0000000107f441bc 0x102eb0000 + 84492732 16 My.App.iOS 0x0000000107f8c470 0x102eb0000 + 84788336 17 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 18 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 19 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 15: 0 libsystem_kernel.dylib 0x00000001dc5dc558 __psynch_cvwait + 8 1 My.App.iOS 0x0000000107ff0fec 0x102eb0000 + 85200876 2 My.App.iOS 0x0000000107f97aa0 0x102eb0000 + 84834976 3 My.App.iOS 0x0000000107f97978 0x102eb0000 + 84834680 4 My.App.iOS 0x0000000107f313c4 0x102eb0000 + 84415428 5 My.App.iOS 0x0000000107f00e28 0x102eb0000 + 84217384 6 My.App.iOS 0x000000010338bd78 0x102eb0000 + 5094776 7 My.App.iOS 0x00000001035b60d0 0x102eb0000 + 7364816 8 My.App.iOS 0x00000001035acce4 0x102eb0000 + 7326948 9 My.App.iOS 0x000000010349014c 0x102eb0000 + 6160716 10 My.App.iOS 0x000000010497954c 0x102eb0000 + 28087628 11 My.App.iOS 0x00000001035b664c 0x102eb0000 + 7366220 12 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 13 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 14 My.App.iOS 0x0000000107f3e820 0x102eb0000 + 84469792 15 My.App.iOS 0x0000000107f441bc 0x102eb0000 + 84492732 16 My.App.iOS 0x0000000107f8c470 0x102eb0000 + 84788336 17 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 18 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 19 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 16: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 17: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 18: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 19: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 20: 0 libsystem_kernel.dylib 0x00000001dc5dc18c __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x00000001fd41cb7c start_wqthread + 4 Thread 21: 0 My.App.iOS 0x0000000107e60534 0x102eb0000 + 83559732 1 My.App.iOS 0x0000000107e576b0 0x102eb0000 + 83523248 2 My.App.iOS 0x0000000107e58168 0x102eb0000 + 83525992 3 My.App.iOS 0x0000000107e7fecc 0x102eb0000 + 83689164 4 My.App.iOS 0x0000000107e87d90 0x102eb0000 + 83721616 5 My.App.iOS 0x000000010348f12c 0x102eb0000 + 6156588 6 My.App.iOS 0x00000001035bde08 0x102eb0000 + 7396872 7 My.App.iOS 0x0000000103fb82d4 0x102eb0000 + 17859284 8 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 9 My.App.iOS 0x0000000107f4010c 0x102eb0000 + 84476172 10 My.App.iOS 0x0000000107f83370 0x102eb0000 + 84751216 11 My.App.iOS 0x0000000107f80be4 0x102eb0000 + 84741092 12 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 13 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 14 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 15 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 22: 0 My.App.iOS 0x0000000107e60534 0x102eb0000 + 83559732 1 My.App.iOS 0x0000000107e576b0 0x102eb0000 + 83523248 2 My.App.iOS 0x0000000107e58168 0x102eb0000 + 83525992 3 My.App.iOS 0x0000000107e7fecc 0x102eb0000 + 83689164 4 My.App.iOS 0x0000000107e87d90 0x102eb0000 + 83721616 5 My.App.iOS 0x000000010348f12c 0x102eb0000 + 6156588 6 My.App.iOS 0x00000001035bde08 0x102eb0000 + 7396872 7 My.App.iOS 0x0000000103fb82d4 0x102eb0000 + 17859284 8 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 9 My.App.iOS 0x0000000107f4010c 0x102eb0000 + 84476172 10 My.App.iOS 0x0000000107f83370 0x102eb0000 + 84751216 11 My.App.iOS 0x0000000107f80be4 0x102eb0000 + 84741092 12 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 13 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 14 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 15 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 23: 0 My.App.iOS 0x0000000107e59478 0x102eb0000 + 83530872 1 My.App.iOS 0x0000000107e87a18 0x102eb0000 + 83720728 2 My.App.iOS 0x000000010348ef9c 0x102eb0000 + 6156188 3 My.App.iOS 0x0000000105c2c700 0x102eb0000 + 47695616 4 My.App.iOS 0x00000001036217c4 0x102eb0000 + 7804868 5 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 6 My.App.iOS 0x00000001035c8e24 0x102eb0000 + 7441956 7 My.App.iOS 0x00000001035c7854 0x102eb0000 + 7436372 8 My.App.iOS 0x0000000103fb82d4 0x102eb0000 + 17859284 9 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 10 My.App.iOS 0x0000000107f4010c 0x102eb0000 + 84476172 11 My.App.iOS 0x0000000107f83370 0x102eb0000 + 84751216 12 My.App.iOS 0x0000000107f80be4 0x102eb0000 + 84741092 13 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 14 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 15 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 16 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 24: 0 My.App.iOS 0x0000000107e60534 0x102eb0000 + 83559732 1 My.App.iOS 0x0000000107e576b0 0x102eb0000 + 83523248 2 My.App.iOS 0x0000000107e58168 0x102eb0000 + 83525992 3 My.App.iOS 0x0000000107e7fecc 0x102eb0000 + 83689164 4 My.App.iOS 0x0000000107e87d90 0x102eb0000 + 83721616 5 My.App.iOS 0x000000010348f12c 0x102eb0000 + 6156588 6 My.App.iOS 0x00000001035bde08 0x102eb0000 + 7396872 7 My.App.iOS 0x0000000103fb82d4 0x102eb0000 + 17859284 8 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 9 My.App.iOS 0x0000000107f4010c 0x102eb0000 + 84476172 10 My.App.iOS 0x0000000107f83370 0x102eb0000 + 84751216 11 My.App.iOS 0x0000000107f80be4 0x102eb0000 + 84741092 12 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 13 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 14 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 15 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 25: 0 My.App.iOS 0x0000000107f24b54 0x102eb0000 + 84364116 1 My.App.iOS 0x0000000107f0dd58 0x102eb0000 + 84270424 2 My.App.iOS 0x0000000107f0c1e8 0x102eb0000 + 84263400 3 My.App.iOS 0x0000000107e6062c 0x102eb0000 + 83559980 4 My.App.iOS 0x0000000107e576b0 0x102eb0000 + 83523248 5 My.App.iOS 0x0000000107e57568 0x102eb0000 + 83522920 6 My.App.iOS 0x0000000107e70760 0x102eb0000 + 83625824 7 My.App.iOS 0x00000001033a1930 0x102eb0000 + 5183792 8 My.App.iOS 0x00000001036ac4f8 0x102eb0000 + 8373496 9 My.App.iOS 0x000000010319f9d8 0x102eb0000 + 3078616 10 My.App.iOS 0x000000010714b270 0x102eb0000 + 69841520 11 My.App.iOS 0x00000001036217c4 0x102eb0000 + 7804868 12 My.App.iOS 0x00000001035b4578 0x102eb0000 + 7357816 13 My.App.iOS 0x00000001035c8e24 0x102eb0000 + 7441956 14 My.App.iOS 0x00000001035c7854 0x102eb0000 + 7436372 15 My.App.iOS 0x0000000103fb82d4 0x102eb0000 + 17859284 16 My.App.iOS 0x0000000107e84bd4 0x102eb0000 + 83708884 17 My.App.iOS 0x0000000107f4010c 0x102eb0000 + 84476172 18 My.App.iOS 0x0000000107f83370 0x102eb0000 + 84751216 19 My.App.iOS 0x0000000107f80be4 0x102eb0000 + 84741092 20 My.App.iOS 0x0000000107f8c378 0x102eb0000 + 84788088 21 My.App.iOS 0x0000000107f8c1fc 0x102eb0000 + 84787708 22 libsystem_pthread.dylib 0x00000001fd41d6b8 _pthread_start + 144 23 libsystem_pthread.dylib 0x00000001fd41cb88 thread_start + 4 Thread 0 crashed with arm64 Thread State: x21: 0x00000001f3f90160 x2: 0x0000000000000000 x16: 0x0000000000000148 x3: 0x0000000000000000 x22: 0x0000000000000000 x4: 0x000000000000000b x17: 0x00000001f3f90080 cpsr: 0x0000000040000000 x5: 0x000000011771bc00 x23: 0x000000010a812c00 x6: 0x0000000000000c00 x18: 0x0000000000000000 x10: 0x0000000000000225 lr: 0x00000001fd423118 x7: 0x0000000000000b00 x24: 0x0000000109676e80 x11: 0x0000000000000000 x8: 0xd779aff9e5fb4525 x19: 0x0000000000000006 x25: 0x000000016cf4be10 x9: 0xd779aff8160245a5 x12: 0x00000001092071e0 fp: 0x000000016cf4b010 x26: 0x0000000000000001 x13: 0x0000000109676e83 pc: 0x00000001dc5e2558 x27: 0x00000001085dde30 x14: 0x00000000000000e0 x20: 0x0000000000000103 x0: 0x0000000000000000 sp: 0x000000016cf4aff0 x28: 0x0000000000ffffff x15: 0x0000000080000000 x1: 0x0000000000000000 Binary Images: 0x0000000102eb0000 - 0x000000010818ffff +My.App.iOS arm64 <6433091d24543decadd76c191b78f997> /private/var/containers/Bundle/Application/136B6E12-1A81-412B-AA35-E6FA2D74724A/My.App.iOS.app/My.App.iOS 0x0000000108a94000 - 0x0000000108f0bfff +libSkiaSharp arm64 /private/var/containers/Bundle/Application/136B6E12-1A81-412B-AA35-E6FA2D74724A/My.App.iOS.app/Frameworks/libSkiaSharp.framework/libSkiaSharp 0x0000000108f6c000 - 0x00000001090d7fff +LiteCore arm64 /private/var/containers/Bundle/Application/136B6E12-1A81-412B-AA35-E6FA2D74724A/My.App.iOS.app/Frameworks/LiteCore.framework/LiteCore 0x0000000197935000 - 0x0000000198212fff Foundation arm64e <6e76dc9611af3b2eb71e215f9cc6e822> /System/Library/Frameworks/Foundation.framework/Foundation 0x000000019d66f000 - 0x000000019da56fff CoreFoundation arm64e <4230c12242e8383bbeecee7b61f8bb61> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 0x000000019e680000 - 0x000000019ea4bfff CFNetwork arm64e <6aafe7c4f1c43020ad1670591c86d7b0> /System/Library/Frameworks/CFNetwork.framework/CFNetwork 0x000000019f6de000 - 0x00000001a0f02fff UIKitCore arm64e /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore 0x00000001a4b82000 - 0x00000001a4bffff3 libsystem_c.dylib arm64e <3548f8ee7a073b678d699c7d42096513> /usr/lib/system/libsystem_c.dylib 0x00000001d8bb2000 - 0x00000001d8bbafff GraphicsServices arm64e /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices 0x00000001dc5db000 - 0x00000001dc612ff7 libsystem_kernel.dylib arm64e <2f78311097393f18a2345fb92512529d> /usr/lib/system/libsystem_kernel.dylib 0x00000001fd41c000 - 0x00000001fd427ff3 libsystem_pthread.dylib arm64e <8894310a745f340799f01fd54442561d> /usr/lib/system/libsystem_pthread.dylib ```

Expected Behavior

The CFSocket and CFData classes should be null compliant. Maybe it is a problem of the Marshal class, then we'd need to take this somewhere else.

Actual Behavior

The CFSocket and CFData classes are not null compliant. If a developer doesn't notice their own mistakes their app will crash on them in some library code.

Environment

Version information ``` Visual Studio Community 2022 for Mac Version 17.5.2 (build 14) Installation UUID: a41e82af-0571-4690-8bc6-ff13103248b3 Runtime .NET 7.0.1 (64-bit) Architecture: Arm64 Microsoft.macOS.Sdk 12.3.2372; git-rev-head:754abbf6a3563f6267e5717ae832b4ac25b1f2fb; git-branch:release/7.0.1xx-xcode13.3 Roslyn (Language Service) 4.5.0-3.23056.2+97881342e427ff5cdcba8f12b12ff8e6f3564431 NuGet Version: 6.4.0.117 Xamarin Designer Version: 17.5.3.47 Hash: e8b5d371c3 Branch: remotes/origin/d17-5 Build date: 2023-03-09 19:43:36 UTC .NET SDK (Arm64) SDK: /usr/local/share/dotnet/sdk/7.0.202/Sdks SDK Versions: 7.0.202 7.0.200 6.0.407 6.0.404 MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks .NET SDK (x64) SDK Versions: 6.0.106 5.0.408 3.1.420 .NET Runtime (Arm64) Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 7.0.4 7.0.3 6.0.15 6.0.12 .NET Runtime (x64) Runtime: /usr/local/share/dotnet/x64/dotnet Runtime Versions: 6.0.6 5.0.17 3.1.26 Xamarin.Profiler Version: 1.8.0.49 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler Updater Version: 11 Apple Developer Tools Xcode: 14.2 21534 Build: 14C18 Xamarin.Mac Version: 9.1.0.5 Visual Studio Community Hash: 7738c90c9 Branch: xcode14.2 Build date: 2023-01-25 15:56:14-0500 Xamarin.iOS Version: 16.2.0.5 Visual Studio Community Hash: 7738c90c9 Branch: xcode14.2 Build date: 2023-01-25 15:56:15-0500 Xamarin.Android Version: 13.2.0.0 (Visual Studio Community) Commit: xamarin-android/d17-5/797e2e1 Android SDK: /Users/gitlab/Library/Android/sdk Supported Android versions: 12.1 (API level 32) 12.0 (API level 31) 11.0 (API level 30) 13.0 (API level 33) SDK Command-line Tools Version: 7.0 SDK Platform Tools Version: 34.0.1 SDK Build Tools Version: 34.0.0 rc2 Build Information: Mono: 6dd9def Java.Interop: xamarin/java.interop/main@149d70fe SQLite: xamarin/sqlite/3.40.0@fdc1e34 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9f02d77 Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.17 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Android SDK Manager Version: 17.5.0.33 Hash: f0c0c52 Branch: remotes/origin/d17-5~2 Build date: 2023-03-09 19:43:41 UTC Android Device Manager Version: 0.0.0.1245 Hash: 7f8a990 Branch: 7f8a990 Build date: 2023-03-09 19:43:41 UTC Build Information Release ID: 1705020014 Git revision: f95e127ba5837148420d81c7c14c47ca8eade102 Build date: 2023-03-09 19:41:47+00 Build branch: release-17.5 Build lane: release-17.5 Operating System Mac OS X 13.2.1 Darwin 22.3.0 Darwin Kernel Version 22.3.0 Mon Jan 30 20:39:35 PST 2023 root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 arm64 ```

Build Logs

build.log

Example Project (If Possible)

As I am not able to reproduce the crash myself I cannot create a test-project which reproduces the error.

dalexsoto commented 1 year ago

CFSocket.cs has been nullability audited already, actually some time ago, that said there is a chance we might have missed something. This seems to be the offending line that your crashlog is referencing:

https://github.com/xamarin/xamarin-macios/blob/6b1f9699ac71b616b272c2496eac5af63d5be195/src/CoreFoundation/CFSocket.cs#L363

Seems like the GetBuffer call is crashing because the of data pointer given to the callback may be invalid. That said that seems to be the state given to the callback by the native side as it is being restored.

  at (wrapper native-to-managed) CoreFoundation.CFSocket.OnCallback(intptr,System.nuint,intptr,intptr,intptr)
  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) <0x103f82330 + 0x0004b> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) <0x103f82410 + 0x000f3> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0
  at My.App.iOS.IosApplication.Main (System.String[] args) <0x10307a218 + 0x00033> in <feed1ae8056b4ac39f951d31d3c7f420#2aaf0db881281529a40d8a19275df360>:0
  at null.null
  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) <0x103f82330 + 0x0004b> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) <0x103f82410 + 0x000f3> in <234f9d1731fd4e1ebf977b0a61b8dd61#2aaf0db881281529a40d8a19275df360>:0
  at My.App.iOS.IosApplication.Main (System.String[] args) <0x10307a218 + 0x00033> in <feed1ae8056b4ac39f951d31d3c7f420#2aaf0db881281529a40d8a19275df360>:0

Without a repro there is not much we can do about it, there is not a good way to know if the CFData given by the callback is valid or not but, we could try to add an IntPtr.Zero check but I am unsure if that will do anything. I know you mentioned you do not have a way to repro this but you may want to have a look at your networking code and make sure to be using the NSUrlSession APIs