Skip to content

[llvm/bitcode] Crash in mono_class_has_failure (class.c:10037)  #7535

Closed

Description

@rolfbjarne

Steps to Reproduce

  1. Download test case: https://bugzilla.xamarin.com/attachment.cgi?id=23568
  2. Open the solution, select the monotouch-test-watchos-app project as the startup project, select a Device|Release configuration and run on device.

Current Behavior

This is the output in the application output:

DownloadDataAsync a
DownloadDataAsync v
DownloadDataAsync f
DownloadDataAsync ii
Xamarin.Hosting: Process '425' exited.

The last part is because the process crashed.

Expected Behavior

No crash.

On which platforms did you notice this

[ ] macOS
[ ] Linux
[ ] Windows
[x] watchOS

Version Used:

xamarin-macios/master with mono's 266326d (tip of the 2017-12 branch).

This comes from here: https://bugzilla.xamarin.com/show_bug.cgi?id=58132, and has been an issue since d15-4.

Stacktrace

Attaching with lldb I get a stack trace:

Process 326 stopped
* thread #1, name = 'tid_d07', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8e466fcb)
    frame #0: 0x00305ba4 monotouchtest`mono_class_has_failure(klass=0x8e466fb5) at class.c:10037 [opt]
(lldb) 
   10034	mono_class_has_failure (const MonoClass *klass)
   10035	{
   10036		g_assert (klass != NULL);
-> 10037		return klass->has_failure != 0;
   10038	}
   10039	
   10040	
(lldb) bt
* thread #1, name = 'tid_d07', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8e466fcb)
  * frame #0: 0x00305ba4 monotouchtest`mono_class_has_failure(klass=0x8e466fb5) at class.c:10037 [opt]
    frame #1: 0x003509a0 monotouchtest`mono_class_vtable_full(domain=0x17517110, klass=0x8e466fb5, error=0x02128a5c) at object.c:1807 [opt]
    frame #2: 0x00352416 monotouchtest`mono_class_vtable(domain=<unavailable>, klass=<unavailable>) at object.c:1783 [opt]
    frame #3: 0x002c2c84 monotouchtest`init_method(amodule=0x178e4000, method_index=<unavailable>, method=0x00000000, init_class=0x8e466fb5, context=<unavailable>, error=<unavailable>) at aot-runtime.c:0 [opt]
    frame #4: 0x002bc7a8 monotouchtest`mono_aot_init_gshared_method_vtable [inlined] init_llvmonly_method(method=<unavailable>) at aot-runtime.c:4397 [opt]
    frame #5: 0x002bc798 monotouchtest`mono_aot_init_gshared_method_vtable(aot_module=0x178e4000, method_index=5071, vtable=<unavailable>) at aot-runtime.c:4471 [opt]
    frame #6: 0x0004bba8 monotouchtest`init_method_gshared_vtable + 44
    frame #7: 0x00201812 monotouchtest`mscorlib_System_Runtime_CompilerServices_TaskAwaiter_1_TResult_BOOL_UnsafeOnCompleted_System_Action + 146
    frame #8: 0x0004a8c0 monotouchtest`monotouchtest_System_Runtime_CompilerServices_AsyncVoidMethodBuilder_AwaitUnsafeOnCompleted_TAwaiter_INST_TStateMachine_REF_TAwaiter_INST__TStateMachine_REF_ + 494
    frame #9: 0x00047ee6 monotouchtest`monotouchtest_monotouchtestWatchKitExtension_InterfaceController__c___DownloadDataAsyncb__2_0d_MoveNext + 1090
    frame #10: 0x0018e57a monotouchtest`mscorlib_System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Start_TStateMachine_REF_TStateMachine_REF_ + 320
    frame #11: 0x00047a4c monotouchtest`monotouchtest_monotouchtestWatchKitExtension_InterfaceController__c__DownloadDataAsyncb__2_0_Foundation_NSTimer + 548
    frame #12: 0x000482b0 monotouchtest`monotouchtest_wrapper_delegate_invoke_System_Action_1_Foundation_NSTimer_invoke_void_T_Foundation_NSTimer + 670
    frame #13: 0x00293e2c monotouchtest`Xamarin_WatchOS_Foundation_NSTimerActionDispatcher_Fire_Foundation_NSTimer + 146
    frame #14: 0x002468cc monotouchtest`mscorlib_wrapper_unknown_object_gsharedvt_out_sig_object__intptr_0 + 38
    frame #15: 0x00230c06 monotouchtest`mscorlib_wrapper_runtime_invoke_object_runtime_invoke_sig_void_intptr_intptr_intptr_object_intptr_intptr_intptr + 376
    frame #16: 0x002f3bfc monotouchtest`mono_llvmonly_runtime_invoke(method=<unavailable>, info=<unavailable>, obj=<unavailable>, params=<unavailable>, exc=<unavailable>, error=<unavailable>) at mini-runtime.c:2600 [opt]
    frame #17: 0x002f0dfa monotouchtest`mono_jit_runtime_invoke(method=<unavailable>, obj=<unavailable>, params=<unavailable>, exc=0x021293b0, error=<unavailable>) at mini-runtime.c:2800 [opt]
    frame #18: 0x003528ca monotouchtest`do_runtime_invoke(method=<unavailable>, obj=<unavailable>, params=0x021293a4, exc=0x021293b0, error=<unavailable>) at object.c:2887 [opt]
    frame #19: 0x00352820 monotouchtest`mono_runtime_invoke [inlined] mono_runtime_try_invoke(method=<unavailable>, obj=0x02385d80, params=0x021293a4, exc=0x021293b0, error=0x00000000) at object.c:2994 [opt]
    frame #20: 0x003527f2 monotouchtest`mono_runtime_invoke(method=0x17930668, obj=0x02385d80, params=0x021293a4, exc=0x021293b0) at object.c:2935 [opt]
    frame #21: 0x00046938 monotouchtest`native_to_managed_trampoline_3(self=0x17579dc0, _cmd="xamarinFireSelector:", managed_method_ptr=0x00487808, p0=0x1757a090, token_ref=91140) at registrar.m:111
    frame #22: 0x00046830 monotouchtest`::-[__Xamarin_NSTimerActionDispatcher xamarinFireSelector:](self=0x17579dc0, _cmd="xamarinFireSelector:", p0=0x1757a090) at registrar.m:331
    frame #23: 0x1b317f66 Foundation`__NSFireTimer + 62
    frame #24: 0x1a9a3860 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 16
    frame #25: 0x1a9a3538 CoreFoundation`__CFRunLoopDoTimer + 872
    frame #26: 0x1a9a2ee6 CoreFoundation`__CFRunLoopDoTimers + 220
    frame #27: 0x1a9a11b4 CoreFoundation`__CFRunLoopRun + 1428
    frame #28: 0x1a8f5f74 CoreFoundation`CFRunLoopRunSpecific + 354
    frame #29: 0x1b23707c Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 246
    frame #30: 0x1b283f5a Foundation`-[NSRunLoop(NSRunLoop) run] + 80
    frame #31: 0x1a7270de libxpc.dylib`_xpc_objc_main + 600
    frame #32: 0x1a7286fe libxpc.dylib`xpc_main + 166
    frame #33: 0x1b40bfea Foundation`-[NSXPCListener resume] + 182
    frame #34: 0x245c71be PlugInKit`-[PKService run] + 774
    frame #35: 0x28433f8c WatchKit`main + 134
    frame #36: 0x003e7160 monotouchtest`::xamarin_main(argc=1, argv=<unavailable>, launch_mode=XamarinLaunchModeExtension) at monotouch-main.m:481 [opt]
    frame #37: 0x000473b6 monotouchtest`::xamarin_watchextension_main(argc=1, argv=0x0212bc20) at main.m:40
(lldb) p *klass
error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory

Activity

  1. added this to the 2017-12 (5.10.xx) milestone on Mar 9, 2018
  2. luhenry commented on Mar 9, 2018

    @luhenry
    Contributor
  3. vargaz commented on Mar 10, 2018

    @vargaz
    Contributor

    Testcase:

    using System;
    using System.Collections.Generic;
    
    public interface ICompletion {
    	void UnsafeOnCompleted ();
    }
    
    public struct TaskAwaiter<T> : ICompletion
    {
    	public void UnsafeOnCompleted () {
    		Console.WriteLine (typeof (T));
    	}
    }
    
    public struct AsyncVoidMethodBuilder
    {
            public void AwaitUnsafeOnCompleted<TAwaiter>(ref TAwaiter awaiter)
                where TAwaiter : ICompletion {
    			awaiter.UnsafeOnCompleted();
    		}
    }
    
    public static class Program {
        public static int Main () {
    		var builder = new AsyncVoidMethodBuilder ();
    		var awaiter = new TaskAwaiter<bool> ();
    		builder.AwaitUnsafeOnCompleted (ref awaiter);
    		return 0;
    	}
    }
  4. added a commit that references this issue on Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions