Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] App Crash on Startup when Interpreter is used with Release configuration. #22205

Open
rolfbjarne opened this issue Feb 18, 2025 · 4 comments
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@rolfbjarne
Copy link
Member

From @darkcamper on Mon, 17 Feb 2025 10:02:17 GMT

Description

When running an iOS app compiled with 'Release' configuration AND the interpreter enabled on an iOS 18.2 simulator, the app crashes on startup. The same app when deployed to a physical device (iPhone SE 3rd Gen on Both iOS 18.2 and 18.3.1) runs without any problem.

Visual Studio 17.3.0 on Windows 10 (22H2, 19045.5487)
.NET SDK 9.0.200
App built on Mac mini m4, MacOs Sequoia 15.3.1, Xcode 16.2

Steps to Reproduce

  1. Create an empty MAUI App using the default provided template on Visual Studio
  2. Enable the interpreter by adding the following to a property group inside the .csproj file;
<MtouchInterpreter>all</MtouchInterpreter>
  1. Select 'Release' configuration
  2. Select iOS Simulators / iPhone 16 iOS 18.2
  3. Press 'Start Without Debugging' button

Link to public reproduction project repository

No response

Version with bug

9.0.40 SR4

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, I was not able test on other platforms

Affected platform versions

iOS 18.2

Did you find any workaround?

No response

Relevant log output

Unhandled managed exception: Failed to lookup the required marshalling information.
Additional information:
	Selector: respondsToSelector:
	Type: AppDelegate
 (ObjCRuntime.RuntimeException)
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at MauiNoChanges.Program.Main(String[] args)
Failed to get the 'this' instance in a method call to Microsoft.Maui.MauiUIApplicationDelegate.RespondsToSelector. (ObjCRuntime.RuntimeException)
   at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
   at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, SByte is_static, IntPtr obj, IntPtr* mthisPtr, IntPtr desc)
   at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cl<>


-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 2BC93BFC-4DCD-4252-9F7C-9E1E77622AFC
CrashReporter Key:   DB47A5D8-F74E-7DED-BC3D-F6C76EA1205A
Hardware Model:      Mac16,10
Process:             MauiNoChanges [13207]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/398E43A3-0AD5-4C55-BA4A-E9AF51C5B62B/data/Containers/Bundle/Application/FD99D4A0-96C6-4888-9984-D54313ACDF96/MauiNoChanges.app/MauiNoChanges
Identifier:          com.companyname.mauinochanges
Version:             1.0 (1)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [1194]
Coalition:           com.apple.CoreSimulator.SimDevice.398E43A3-0AD5-4C55-BA4A-E9AF51C5B62B [1164]
Responsible Process: SimulatorTrampoline [1140]

Date/Time:           2025-02-17 10:23:44.6244 +0100
Launch Time:         2025-02-17 10:23:43.3115 +0100
OS Version:          macOS 15.3.1 (24D70)
Release Type:        User
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: MauiNoChanges [13207]

Triggered by Thread:  0

Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter


Thread 0 Crashed:: tid_103 Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x11e029108 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x11e5d3408 pthread_kill + 256
2   libsystem_c.dylib             	       0x11da634ec abort + 104
3   libmonosgen-2.0.dylib         	       0x1050633c4 sigabrt_signal_handler.cold.1 + 48
4   libmonosgen-2.0.dylib         	       0x104eeb15c sigabrt_signal_handler + 196
5   libsystem_platform.dylib      	       0x11e1443c0 _sigtramp + 52
6   libsystem_pthread.dylib       	       0x11e5d3408 pthread_kill + 256
7   libsystem_c.dylib             	       0x11da634ec abort + 104
8   libxamarin-dotnet.dylib       	       0x104b22ccc xamarin_unhandled_exception_handler + 60
9   libmonosgen-2.0.dylib         	       0x104f7bac8 mono_invoke_unhandled_exception_hook + 156
10  libmonosgen-2.0.dylib         	       0x104e5b9cc mono_jit_exec + 404
11  libxamarin-dotnet.dylib       	       0x104b2c678 xamarin_main + 940
12  MauiNoChanges                 	       0x1033cb898 main + 64 (main.arm64.mm:76)
13  dyld_sim                      	       0x104515410 start_sim + 20
14  dyld                          	       0x10465e274 start + 2840

Thread 1:
0   libsystem_pthread.dylib       	       0x11e5ce92c start_wqthread + 0

Thread 2:: SGen worker
0   libsystem_kernel.dylib        	       0x11e02482c __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x11e5d3c98 _pthread_cond_wait + 1192
2   libmonosgen-2.0.dylib         	       0x105060e6c thread_func + 412
3   libsystem_pthread.dylib       	       0x11e5d36f8 _pthread_start + 104
4   libsystem_pthread.dylib       	       0x11e5ce940 thread_start + 8

Thread 3:: Finalizer
0   libsystem_kernel.dylib        	       0x11e02130c semaphore_wait_trap + 8
1   libmonosgen-2.0.dylib         	       0x10500603c finalizer_thread + 340
2   libmonosgen-2.0.dylib         	       0x104fdee90 start_wrapper + 340
3   libsystem_pthread.dylib       	       0x11e5d36f8 _pthread_start + 104
4   libsystem_pthread.dylib       	       0x11e5ce940 thread_start + 8

Thread 4:
0   libsystem_pthread.dylib       	       0x11e5ce92c start_wqthread + 0

Thread 5:
0   libsystem_pthread.dylib       	       0x11e5ce92c start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib       	       0x11e5ce92c start_wqthread + 0

Thread 7:: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib        	       0x11e021390 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x11e0326e0 mach_msg2_internal + 76
2   libsystem_kernel.dylib        	       0x11e0294f4 mach_msg_overwrite + 536
3   libsystem_kernel.dylib        	       0x11e0216cc mach_msg + 20
4   CoreFoundation                	       0x1096e3ad0 __CFRunLoopServiceMachPort + 156
5   CoreFoundation                	       0x1096ddff8 __CFRunLoopRun + 1160
6   CoreFoundation                	       0x1096dd6f4 CFRunLoopRunSpecific + 552
7   Foundation                    	       0x111d4d438 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208
8   Foundation                    	       0x111d4d658 -[NSRunLoop(NSRunLoop) runUntilDate:] + 60
9   UIKitCore                     	       0x149700284 -[UIEventFetcher threadMain] + 404
10  Foundation                    	       0x111d74280 __NSThread__start__ + 720
11  libsystem_pthread.dylib       	       0x11e5d36f8 _pthread_start + 104
12  libsystem_pthread.dylib       	       0x11e5ce940 thread_start + 8

Thread 8:
0   libsystem_pthread.dylib       	       0x11e5ce92c start_wqthread + 0

Thread 9:
0   libsystem_pthread.dylib       	       0x11e5ce92c start_wqthread + 0


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0xffffffff97b8a85c   x5: 0x0000000000000018   x6: 0x000000016d505830   x7: 0x000000016d504f20
    x8: 0x00000001046e8200   x9: 0x2ad2e4f6504958bc  x10: 0x3d3d3d3d3d3d3d3d  x11: 0x3d3d3d3d3d3d3d3d
   x12: 0x3d3d3d3d3d3d3d3d  x13: 0x3d3d3d3d3d3d3d3d  x14: 0x3d3d3d3d3d3d3d3d  x15: 0x0a3d3d3d3d3d3d3d
   x16: 0x0000000000000148  x17: 0x00000001096b8978  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000000103  x21: 0x00000001046e82e0  x22: 0x000000031631a200  x23: 0x0000000000000001
   x24: 0x0000600002efc6c0  x25: 0x0000000000000000  x26: 0x0000000000000000  x27: 0x000000016d50692a
   x28: 0x00006000027fc410   fp: 0x000000016d505840   lr: 0x000000011e5d3408
    sp: 0x000000016d505820   pc: 0x000000011e029108 cpsr: 0x40000000
   far: 0x0000000000000000  esr: 0x56000080  Address size fault

Copied from original issue dotnet/maui#27840

@rolfbjarne
Copy link
Member Author

From @drasticactions on Tue, 18 Feb 2025 07:14:13 GMT

Trying this, UseInterpreter worked where MtouchInterpreter didn't with the same stack you have, even though they should do the same thing I think?

@rolfbjarne What do you think?

@rolfbjarne
Copy link
Member Author

From @darkcamper on Tue, 18 Feb 2025 07:33:46 GMT

@drasticactions I just gave it a try to see if it made any difference, but the app is still crashing with the same error

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Tue, 18 Feb 2025 12:59:04 GMT

I can reproduce this.

A workaround is to add this to the csproj:

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <Registrar>static</Registrar>
</PropertyGroup>

@darkcamper
Copy link

I applied the workaround and it worked for me. Thanks!

@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Feb 18, 2025
@rolfbjarne rolfbjarne added this to the .NET 10 milestone Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
Development

No branches or pull requests

2 participants