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

.NET/iOS: crash on device #10726

Closed
rolfbjarne opened this issue Feb 25, 2021 · 5 comments
Closed

.NET/iOS: crash on device #10726

rolfbjarne opened this issue Feb 25, 2021 · 5 comments
Labels
bug If an issue is a bug or a pull request a bug fix dotnet-external-dependency .NET: this issue/pull request is blocked on external work dotnet-pri0 .NET 6: required for stable release iOS Issues affecting iOS
Milestone

Comments

@rolfbjarne
Copy link
Member

Steps to Reproduce

cd tests/dotnet/MySingleView
dotnet build -t:Run /p:RuntimeIdentifier=ios-arm64

Expected Behavior

Successful launch

Actual Behavior

[...]
Launched application 'com.xamarin.mysingletitle' on 'Rolf's iPhone 11' with pid 6124
Press enter to terminate the application
>2021-02-25 14:55:59.711 MySingleView[6124:6566440] Xamarin.iOS: IDE Port: 10000 Transport: USB
2021-02-25 14:56:01.701 MySingleView[6124:6566403] Xamarin.iOS: Debugger not loaded (timed out while trying to connect to the IDE).
2021-02-25 14:56:01.716 MySingleView[6124:6566440] Xamarin.iOS: Listened for connections from the IDE for 2 seconds, nobody connected.
2021-02-25 14:56:01.741 MySingleView[6124:6566403] Unhandled managed exception: TypeInitialization_Type, System.Collections.Generic.NonRandomizedStringEqualityComparer (System.TypeInitializationException)
 --- inner exception ---
Linked away (System.NotSupportedException)

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGABRT 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:
=================================================================
	0x10564b350 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_dump_native_crash_info
	0x105635094 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_handle_native_crash
	0x10564a720 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : sigabrt_signal_handler
	0x19ae61414 - /usr/lib/system/libsystem_platform.dylib : <redacted>
	0x19ae64948 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x19adf3ba4 - /usr/lib/system/libsystem_c.dylib : abort
	0x1054a6ed0 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : xamarin_printf
	0x1054f6424 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_invoke_unhandled_exception_hook
	0x105634a9c - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_handle_exception_internal
	0x105633354 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_handle_exception
	0x105648b4c - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_arm_throw_exception
	0x10545ebfc - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : rethrow_preserve_exception
	0x10529e454 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : System_Collections_Generic_Dictionary_2_TKey_REF_TValue_REF__ctor_int
	0x10504e548 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : System_AppContext_Setup_char___char___int
	0x10540ad90 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
	0x1056165bc - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_jit_runtime_invoke
	0x10553e464 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_runtime_invoke_checked
	0x1054d0e8c - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_runtime_install_appctx_properties
	0x1054d03b8 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_runtime_init_checked
	0x105615cf0 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mini_init
	0x10561f168 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : mono_jit_init_version
	0x1054b7a5c - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : xamarin_main
	0x1056931b0 - /private/var/containers/Bundle/Application/11B8F971-2D82-4A06-BAF0-2850CBE1EC32/PublicStaging.app/MySingleView : main
	0x19af4f384 - /usr/lib/system/libdyld.dylib : <redacted>

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x19af44df0):0x19af44de0  c0 03 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._..._..)......
0x19af44df0  e3 00 00 54 fd 7b bf a9 fd 03 00 91 bb 78 ff 97  ...T.{.......x..
0x19af44e00  bf 03 00 91 fd 7b c1 a8 c0 03 5f d6 c0 03 5f d6  .....{...._..._.
0x19af44e10  90 29 80 d2 01 10 00 d4 e3 00 00 54 fd 7b bf a9  .).........T.{..

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================
Xamarin.Hosting: Process '6124' exited.
Application 'com.xamarin.mysingletitle' terminated.

This is with 861df21.

@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS dotnet-pri0 .NET 6: required for stable release labels Feb 25, 2021
@rolfbjarne rolfbjarne added this to the .NET 6 milestone Feb 25, 2021
@spouliot
Copy link
Contributor

Linked away (System.NotSupportedException)

Interesting. That's mostly AppDomain / remoting / CAS code - most of it should not even be in dotnet BCL.

I can have a look next week. Also using mtouch --nolinkaway should turn it off.

@rolfbjarne
Copy link
Member Author

We're not linking away anything in .NET anymore, so this isn't our code.

It seems it's System.RuntimeType.UnderlyingSystemType that was linked away:

// from the linked System.Private.CoreLib.dll
.method public virtual hidebysig specialname 
    instance default class System.Type get_UnderlyingSystemType ()  cil managed noinlining 
{
	// Method begins at RVA 0x51cc
	// Code size 11 (0xb)
	.maxstack 8
	IL_0000:  ldstr "Linked away"
	IL_0005:  newobj instance void class System.NotSupportedException::'.ctor'(string)
	IL_000a:  throw 
} // end of method RuntimeType::get_UnderlyingSystemType

it also happens very early (as a result of calling mono_jit_init_version):

(lldb) bt
* thread #1, name = 'tid_407', queue = 'com.apple.main-thread', stop reason = breakpoint 1.22
  * frame #0: 0x000000010321a9f0 MySingleView`throw_exception
    frame #1: 0x0000000102de7754 MySingleView`System_RuntimeType_get_UnderlyingSystemType + 148
    frame #2: 0x0000000102e0307c MySingleView`System_Type_IsAssignableFrom_System_Type + 396
    frame #3: 0x0000000103058174 MySingleView`System_Collections_Generic_EqualityComparer_1_T_REF_CreateComparer + 484
    frame #4: 0x0000000103057e6c MySingleView`System_Collections_Generic_EqualityComparer_1_T_REF_get_Default + 236
    frame #5: 0x000000010306b918 MySingleView`System_Collections_Generic_NonRandomizedStringEqualityComparer__cctor + 120
    frame #6: 0x00000001031c6d90 MySingleView`wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 560
    frame #7: 0x00000001033d25bc MySingleView`mono_jit_runtime_invoke(method=<unavailable>, obj=<unavailable>, params=<unavailable>, exc=<unavailable>, error=0x000000016d0d6780) at mini-runtime.c:3383:3 [opt]
    frame #8: 0x00000001032fbdf0 MySingleView`mono_runtime_try_invoke [inlined] do_runtime_invoke(method=0x0000000105818078, obj=0x0000000000000000, params=0x0000000000000000, exc=0x000000016d0d6188, error=0x000000016d0d6780) at object.c:2472:11 [opt]
    frame #9: 0x00000001032fbdb4 MySingleView`mono_runtime_try_invoke(method=0x0000000105818078, obj=0x0000000000000000, params=0x0000000000000000, exc=0x000000016d0d6188, error=0x000000016d0d6780) at object.c:2581 [opt]
    frame #10: 0x00000001032faa54 MySingleView`mono_runtime_class_init_full(vtable=0x000000010401e3b8, error=0x000000016d0d6780) at object.c:552:3 [opt]
    frame #11: 0x00000001033cd1ec MySingleView`mono_resolve_patch_target(method=0x0000000105817750, domain=0x0000000103e05930, code=", patch_info=0x0000000105814878, run_cctors=1, error=0x000000016d0d6780) at mini-runtime.c:1526:10 [opt]
    frame #12: 0x00000001033e3798 MySingleView`init_method(amodule=0x000000010401f200, info=<unavailable>, method_index=<unavailable>, method=<unavailable>, init_class=0x0000000000000000, error=0x000000016d0d6780) at aot-runtime.c:4845:12 [opt]
    frame #13: 0x00000001033e4730 MySingleView`load_method(domain=0x0000000103e05930, amodule=0x000000010401f200, image=0x000000010401ea00, method=0x0000000105817750, token=100668525, method_index=5228, error=0x000000016d0d6780) at aot-runtime.c:4437:10 [opt]
    frame #14: 0x00000001033e4090 MySingleView`mono_aot_get_method(domain=0x0000000103e05930, method=0x0000000105817750, error=0x000000016d0d6780) at aot-runtime.c:5137:19 [opt]
    frame #15: 0x00000001033cda44 MySingleView`mono_jit_compile_method_with_opt(method=0x0000000281624b40, opt=<unavailable>, jit_only=0, error=0x000000016d0d6780) at mini-runtime.c:2612:10 [opt]
    frame #16: 0x00000001033f3634 MySingleView`common_call_trampoline(regs=0x000000016d0d6810, code="?\x13@, m=0x0000000281624b40, vt=0x0000000000000000, vtable_slot=<unavailable>, error=0x000000016d0d6780) at mini-trampolines.c:636:27 [opt]
    frame #17: 0x00000001033f311c MySingleView`mono_magic_trampoline(regs=0x000000016d0d6810, code="?\x13@, arg=0x0000000281624ae0, tramp=<unavailable>) at mini-trampolines.c:774:8 [opt]
    frame #18: 0x0000000103219e2c MySingleView`generic_trampoline_jit + 252
    frame #19: 0x000000010305a454 MySingleView`System_Collections_Generic_Dictionary_2_TKey_REF_TValue_REF__ctor_int + 132
    frame #20: 0x0000000102e0a548 MySingleView`System_AppContext_Setup_char___char___int + 168
    frame #21: 0x00000001031c6d90 MySingleView`wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 560
    frame #22: 0x00000001033d25bc MySingleView`mono_jit_runtime_invoke(method=<unavailable>, obj=<unavailable>, params=<unavailable>, exc=<unavailable>, error=0x000000016d0d6e30) at mini-runtime.c:3383:3 [opt]
    frame #23: 0x00000001032fa464 MySingleView`mono_runtime_invoke_checked [inlined] do_runtime_invoke(method=0x0000000105813dd0, obj=0x0000000000000000, params=0x000000016d0d6e80, exc=<unavailable>, error=0x000000016d0d6e30) at object.c:2472:11 [opt]
    frame #24: 0x00000001032fa428 MySingleView`mono_runtime_invoke_checked(method=0x0000000105813dd0, obj=0x0000000000000000, params=0x000000016d0d6e80, error=0x000000016d0d6e30) at object.c:2640 [opt]
    frame #25: 0x000000010328ce8c MySingleView`mono_runtime_install_appctx_properties at appdomain.c:1350:2 [opt]
    frame #26: 0x000000010328c3b8 MySingleView`mono_runtime_init_checked(domain=0x0000000103e05930, start_cb=<unavailable>, attach_cb=<unavailable>, error=0x000000016d0d70a8) at appdomain.c:322:3 [opt]
    frame #27: 0x00000001033d1cf0 MySingleView`mini_init(filename=<unavailable>, runtime_version=<unavailable>) at mini-runtime.c:4550:2 [opt]
    frame #28: 0x00000001033db168 MySingleView`mono_jit_init_version(domain_name=<unavailable>, runtime_version=<unavailable>) at driver.c:2851:20 [opt]
    frame #29: 0x0000000103273a5c MySingleView`xamarin_main(argc=1, argv=0x000000016d0d7b20, launch_mode=XamarinLaunchModeApp) at monotouch-main.m:431:2
    frame #30: 0x000000010344f1b0 MySingleView`main(argc=1, argv=0x000000016d0d7b20) at main.arm64.mm:63:11
    frame #31: 0x000000019af4f384 libdyld.dylib`start + 4

@marek-safar
Copy link
Contributor

This should be fixed with dotnet/runtime#48710

@rolfbjarne
Copy link
Member Author

This should be fixed with dotnet/runtime#48710

Looks like that would do it; now we'll just have to wait for updated .NET builds to test it (the fix is 2 days old, and the latest .NET build (6.0.100-preview.3.21123.4) is 3 days old).

@rolfbjarne rolfbjarne added the dotnet-external-dependency .NET: this issue/pull request is blocked on external work label Feb 26, 2021
@spouliot
Copy link
Contributor

spouliot commented Apr 6, 2021

the startup crashes (this one and the AOT one) are fixed with 6.0.100-preview.3.21202.5

@spouliot spouliot closed this as completed Apr 6, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix dotnet-external-dependency .NET: this issue/pull request is blocked on external work dotnet-pri0 .NET 6: required for stable release iOS Issues affecting iOS
Projects
None yet
Development

No branches or pull requests

3 participants