NSData.FromArray crashing on iOS 14.8 device with segv after updating VS/XCode. Works on iOS 15 simulator.

asked 2021-11-10T15:53:22.477+00:00
Spencer Dube 1 Reputation point

As described in the title I'm getting a case of NSData.FromArray crashing on an iOS 14.8 device with segv after updating VS/XCode to versions 8.10.13 (build 11) and 13.1 respectively.

The error occurs with this information when run on an iphone 12 Pro Max running iOS 14.8:

 =================================================================  
    	Native Crash Reporting  
    =================================================================  
    Got a segv while executing native code. This usually indicates  
    a fatal error in the mono runtime or one of the native libraries   
    used by your application.  
    =================================================================  
      
    =================================================================  
    	Native stacktrace:  
    =================================================================  
    	0x100f32d48 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : sqlite3_sourceid  
    	0x100f28ec0 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : sqlite3_sourceid  
    	0x100f371c8 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x1eba7029c - /usr/lib/system/libsystem_platform.dylib : <redacted>  
    	0x1a0f03d80 - /System/Library/Frameworks/Foundation.framework/Foundation : <redacted>  
    	0x1a0f06798 - /System/Library/Frameworks/Foundation.framework/Foundation : <redacted>  
    	0x1010e4438 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x1010e2b6c - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x1010d9a60 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x1010d7ff0 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x100f3a524 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x100ff4d6c - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x100ff85ac - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x100ed3d00 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : sqlite3_sourceid  
    	0x100ed3b00 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : sqlite3_sourceid  
    	0x1ac3e9708 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac49bcb0 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac456a80 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac4569e8 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac753514 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac11729c - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac49655c - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac0f8a90 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1ac0f8384 - /System/Library/Frameworks/WebKit.framework/WebKit : <redacted>  
    	0x1aa05c904 - /System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore : <redacted>  
    	0x1aa05d8d4 - /System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore : <redacted>  
    	0x19fc1507c - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>  
    	0x19fc14f78 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>  
    	0x19fc1427c - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>  
    	0x19fc0e25c - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>  
    	0x19fc0d9f4 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific  
    	0x1b72de734 - /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal  
    	0x1a268b75c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>  
    	0x1a2690fcc - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain  
    	0x1010e4438 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x1010e2b6c - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x1010d9a60 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x1010d7ff0 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : _ZN16XamarinCallState3selEv  
    	0x100f3a524 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x100ff4d6c - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x100ffb020 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : mono_pmip  
    	0x100f18a20 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : sqlite3_sourceid  
    	0x1010d60bc - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : xamarin_GetFolderPath  
    	0x100edfd28 - /private/var/containers/Bundle/Application/7E3C9F49-AC12-4629-A2D0-5C6FE60748B4/MyApp.app/MyApp : sqlite3_sourceid  
    	0x19f8c9cf8 - /usr/lib/system/libdyld.dylib : <redacted>  
      
    =================================================================  
    	Basic Fault Address Reporting  
    =================================================================  
    Memory around native instruction pointer (0x1eba70654):0x1eba70644  42 00 01 f1 e9 00 00 54 60 04 00 ac 63 80 00 91  B......T`...c...  
    0x1eba70654  20 04 40 ac 21 80 00 91 42 80 00 f1 68 ff ff 54   .@.!...B...h..T  
    0x1eba70664  21 00 02 8b 22 0c 40 ac 60 04 00 ac 63 00 02 8b  !...".@.`...c...  
    0x1eba70674  62 0c 01 ac c0 03 5f d6 63 80 00 91 63 e8 7b 92  b....._.c...c.{.  
      
    =================================================================  
    	Managed Stacktrace:  
    =================================================================  
    	  at <unknown> <0xffffffff>  
    	  at ObjCRuntime.Messaging:IntPtr_objc_msgSend_IntPtr_UIntPtr <0x00022>  
    	  at Foundation.NSData:FromBytes <0x00040>  
    	  at Foundation.NSData:FromArray <0x0007a>  
    	  at MyApp.WebInterpreterProtocol:StartLoading <0x000d8>  
    	  at MyApp.MyHandler:StartUrlSchemeTask <0x00028>  
    	  at <Module>:runtime_invoke_direct_void__this___WKWebView_IWKUrlSchemeTask <0x000be>  
    	  at <unknown> <0xffffffff>  
    	  at UIKit.UIApplication:UIApplicationMain <0x000b8>  
    	  at UIKit.UIApplication:Main <0x000b2>  
    	  at MyApp.application:Main <0x00012>  
    	  at <Module>:runtime_invoke_direct_void_string[] <0x00092>  
    =================================================================  

When I run the exact same codebase and config on the simulator running iOS 15 there is no issue. The failure in question is when calling NSData.FromArray with a byte array representing a .css file or a .js file, but happens even if I provide a fresh byte array of a few arbitrary bytes. Did something change to NSData.FromArray that would cause it to fail on iOS 14.X but not in iOS 15 with the current versions of VS/XCode/.NET?

Here are the VS for Mac details on my install:

=== Visual Studio Community 2019 for Mac ===  
  
Version 8.10.13 (build 11)  
Installation UUID: 5997c116-773b-4abd-aee6-a0f7edea4d91  
	GTK+ 2.24.23 (Raleigh theme)  
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)  
  
	Package version: 612000140  
  
=== Mono Framework MDK ===  
  
Runtime:  
	Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit)  
	Package version: 612000140  
  
=== Roslyn (Language Service) ===  
  
3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb  
  
=== NuGet ===  
  
Version: 5.9.0.7134  
  
=== .NET Core SDK ===  
  
SDK: /usr/local/share/dotnet/sdk/5.0.403/Sdks  
SDK Versions:  
	5.0.403  
	5.0.103  
	5.0.102  
	3.1.415  
	3.1.406  
	3.1.405  
	3.1.402  
	3.1.302  
	3.1.200  
	3.1.101  
	3.1.100  
	3.0.101  
	3.0.100  
	2.1.701  
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks  
  
=== .NET Core Runtime ===  
  
Runtime: /usr/local/share/dotnet/dotnet  
Runtime Versions:  
	5.0.12  
	5.0.3  
	5.0.2  
	3.1.21  
	3.1.12  
	3.1.11  
	3.1.8  
	3.1.6  
	3.1.2  
	3.1.1  
	3.1.0  
	3.0.1  
	3.0.0  
	2.1.23  
	2.1.22  
	2.1.20  
	2.1.16  
	2.1.15  
	2.1.14  
	2.1.13  
	2.1.12  
  
=== .NET Core 3.1 SDK ===  
  
SDK: 3.1.415  
  
=== Xamarin.Profiler ===  
  
Version: 1.6.12.29  
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler  
  
=== Updater ===  
  
Version: 11  
  
=== Xamarin Designer ===  
  
Version: 16.11.0.39  
Hash: cd672761d  
Branch: remotes/origin/d16-11  
Build date: 2021-10-06 20:09:18 UTC  
  
=== Xamarin.Android ===  
  
Not Installed  
  
=== Eclipse Temurin JDK ===  
  
Java SDK: Not Found  
  
Android Designer EPL code available here:  
https://github.com/xamarin/AndroidDesigner.EPL  
  
=== Android SDK Manager ===  
  
Version: 16.10.0.13  
Hash: 1b81df5  
Branch: remotes/origin/d16-10  
Build date: 2021-09-28 20:47:12 UTC  
  
=== Android Device Manager ===  
  
Version: 16.10.0.15  
Hash: 89dcc0b  
Branch: remotes/origin/d16-10  
Build date: 2021-09-28 20:47:30 UTC  
  
=== Apple Developer Tools ===  
  
Xcode 13.1 (19466)  
Build 13A1030d  
  
=== Xamarin.Mac ===  
  
Version: 8.2.0.1 (Visual Studio Community)  
Hash: 8fd9e6289  
Branch: xcode13.1  
Build date: 2021-10-26 10:13:55-0400  
  
=== Xamarin.iOS ===  
  
Version: 15.2.0.1 (Visual Studio Community)  
Hash: 8fd9e6289  
Branch: xcode13.1  
Build date: 2021-10-26 10:13:56-0400  
  
=== Build Information ===  
  
Release ID: 810130011  
Git revision: 53e3946a0f6b630a1124eb7ff26c1b545d040d32  
Build date: 2021-11-04 11:20:46-04  
Build branch: release-8.10  
  
=== Operating System ===  
  
Mac OS X 10.16.0  
Darwin 21.1.0 Darwin Kernel Version 21.1.0  
    Wed Oct 13 17:33:23 PDT 2021  
    root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64  

Any assistance would be greatly appreciated!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
4,803 questions
{count} votes