[Mono-osx] Generic method failing "at mini-generic-sharing.c:407, condition `!(*oti)->data' not met"

Phi Le iamphi at gmail.com
Thu Sep 29 19:22:59 EDT 2011


Hello osx mono developers,

I am getting  "* Assertion at mini-generic-sharing.c:407, condition
`!(*oti)->data' not met " and the application crash when using  generic
method in a particular way.  If AttachedProperty is made into a class
instead of struct then SetAttachedProperty works, but not
GetAttachedProperty.

If I replace those methods with equivalent extension methods, the problem
goes way (AttachedProperty still a struct).  

I am experiencing this with mono 2.10.4 and 2.10.5 on os x 10.6 and 10.7.

Phi

### Generic methods that break (full code):
 public struct AttachedProperty<T> {
        public string Name { get; private set; }
        public T DefaultValue { get; private set; }

        public AttachedProperty(string name, T defaultValue) : this() {
            Name = name;
            DefaultValue = defaultValue;
        }

        public Type PropertyType {
            get { return typeof(T); }
        }
    }

 internal readonly TypedHashtable&lt;object, object&gt; _AttachedProperties
= new TypedHashtable&lt;object, object&gt;();

        public void SetAttachedProperty<T>(AttachedProperty<T> prop, T val)
{
            _AttachedProperties[prop] = val;
        }

        public T GetAttachedProperty<T>(AttachedProperty<T> prop) {
            return (T)(_AttachedProperties[prop] ?? prop.DefaultValue);
        }

### Replacement extension methods:
       public static void SetAttachedProperty<T>(this WindowlessControl c,
AttachedProperty<T> prop, T val) {
            c._AttachedProperties[prop] = val;
        }

        public static T GetAttachedProperty<T>(this WindowlessControl c,
AttachedProperty<T> prop) {
            return (T)(c._AttachedProperties[prop] ?? prop.DefaultValue);
        }

### Crash information:

* Assertion at mini-generic-sharing.c:407, condition `!(*oti)->data' not met

	0   GenericTest                         0x000b98e6
mono_handle_native_sigsegv + 422
	1   libSystem.B.dylib                   0x94fc145b _sigtramp + 43
	2   ???                                 0xffffffff 0x0 + 4294967295
	3   libSystem.B.dylib                   0x9504e899 raise + 26
	4   libSystem.B.dylib                   0x950649b8 abort + 93
	5   GenericTest                         0x00256c41 monoeg_g_logv + 197
	6   GenericTest                         0x00256ca3 monoeg_assertion_message
+ 46
	7   GenericTest                         0x000c3672
rgctx_template_set_other_slot + 642
	8   GenericTest                         0x000c47fd
fill_in_rgctx_template_slot + 61
	9   GenericTest                         0x000c488a
fill_in_rgctx_template_slot + 202
	10  GenericTest                         0x000c488a
fill_in_rgctx_template_slot + 202
	11  GenericTest                         0x000c488a
fill_in_rgctx_template_slot + 202
	12  GenericTest                         0x000c488a
fill_in_rgctx_template_slot + 202
	13  GenericTest                         0x000c4b15
mono_method_lookup_or_register_other_info + 533
	14  GenericTest                         0x00008162
mono_resolve_patch_target + 1698
	15  GenericTest                         0x000eba57 mono_arch_patch_code +
87
	16  GenericTest                         0x0000bae5 mono_codegen + 1269
	17  GenericTest                         0x0000df37 mini_method_compile +
8167
	18  GenericTest                         0x0000fbd6
mono_jit_compile_method_with_opt + 1574
	19  GenericTest                         0x0001051a mono_jit_compile_method
+ 42
	20  GenericTest                         0x001bc07e mono_compile_method + 73
	21  GenericTest                         0x000bb760 common_call_trampoline +
512
	22  ???                                 0x00425066 0x0 + 4345958
	23  ???                                 0x056c8eca 0x0 + 91000522
	24  ???                                 0x056c8e1f 0x0 + 91000351
	25  ???                                 0x056c8d02 0x0 + 91000066
	26  ???                                 0x056c6c88 0x0 + 90991752
	27  ???                                 0x056c6c50 0x0 + 90991696
	28  ???                                 0x056c4850 0x0 + 90982480
	29  ???                                 0x056c45f4 0x0 + 90981876
	30  ???                                 0x056c3560 0x0 + 90977632
	31  ???                                 0x056c4598 0x0 + 90981784
	32  ???                                 0x056c3135 0x0 + 90976565
	33  GenericTest                         0x00010624 mono_jit_runtime_invoke
+ 164
	34  GenericTest                         0x001c1032 mono_runtime_invoke +
137
	35  GenericTest                         0x001c40f6
mono_runtime_invoke_array + 1831
	36  GenericTest                         0x00154f6f ves_icall_InternalInvoke
+ 1163
	37  ???                                 0x052a6de8 0x0 + 86666728
	38  ???                                 0x052a6b98 0x0 + 86666136
	39  ???                                 0x052a6a4b 0x0 + 86665803
	40  ???                                 0x052a5ff4 0x0 + 86663156
	41  ???                                 0x023d914c 0x0 + 37589324
	42  mobjc-glue.dylib                    0x02a68dd5 Thunk + 37
	43  libffi.dylib                        0x95857b9f ffi_closure_SYSV_inner +
177
	44  libffi.dylib                        0x958579c2 ffi_closure_SYSV + 34
	45  AppKit                              0x96d6fcf8 -[NSWindow sendEvent:] +
5693
	46  AppKit                              0x96c88817 -[NSApplication
sendEvent:] + 6431
	47  AppKit                              0x96c1c2a7 -[NSApplication run] +
917
	48  AppKit                              0x96c142d9 NSApplicationMain + 574
	49  ???                                 0x052b82b0 0x0 + 86737584
	50  ???                                 0x052b81f8 0x0 + 86737400
	51  ???                                 0x004aedf8 0x0 + 4910584
	52  ???                                 0x004aeecf 0x0 + 4910799
	53  GenericTest                         0x00010624 mono_jit_runtime_invoke
+ 164
	54  GenericTest                         0x001c1032 mono_runtime_invoke +
137
	55  GenericTest                         0x001c3940 mono_runtime_exec_main +
669
	56  GenericTest                         0x001c2c7a mono_runtime_run_main +
843
	57  GenericTest                         0x0008943d mono_main + 7773
	58  GenericTest                         0x00002db5 start + 53


--
View this message in context: http://mono.1490590.n4.nabble.com/Generic-method-failing-at-mini-generic-sharing-c-407-condition-oti-data-not-met-tp3858093p3858093.html
Sent from the Mono - OSX mailing list archive at Nabble.com.


More information about the Mono-osx mailing list