Open Tobi-Tobi opened 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:
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
Steps to Reproduce
I do have crash reports:
Crash report one.log
Here is the crash report from the AppCenter, yet again that probably got less information:
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.