Please file a bug report with a test case attached.<div><br></div><div><br><br><div class="gmail_quote">On Thu, Sep 29, 2011 at 8:22 PM, Phi Le <span dir="ltr">&lt;<a href="mailto:iamphi@gmail.com">iamphi@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello osx mono developers,<br>
<br>
I am getting  &quot;* Assertion at mini-generic-sharing.c:407, condition<br>
`!(*oti)-&gt;data&#39; not met &quot; and the application crash when using  generic<br>
method in a particular way.  If AttachedProperty is made into a class<br>
instead of struct then SetAttachedProperty works, but not<br>
GetAttachedProperty.<br>
<br>
If I replace those methods with equivalent extension methods, the problem<br>
goes way (AttachedProperty still a struct).<br>
<br>
I am experiencing this with mono 2.10.4 and 2.10.5 on os x 10.6 and 10.7.<br>
<br>
Phi<br>
<br>
### Generic methods that break (full code):<br>
 public struct AttachedProperty&lt;T&gt; {<br>
        public string Name { get; private set; }<br>
        public T DefaultValue { get; private set; }<br>
<br>
        public AttachedProperty(string name, T defaultValue) : this() {<br>
            Name = name;<br>
            DefaultValue = defaultValue;<br>
        }<br>
<br>
        public Type PropertyType {<br>
            get { return typeof(T); }<br>
        }<br>
    }<br>
<br>
 internal readonly TypedHashtable&amp;lt;object, object&amp;gt; _AttachedProperties<br>
= new TypedHashtable&amp;lt;object, object&amp;gt;();<br>
<br>
        public void SetAttachedProperty&lt;T&gt;(AttachedProperty&lt;T&gt; prop, T val)<br>
{<br>
            _AttachedProperties[prop] = val;<br>
        }<br>
<br>
        public T GetAttachedProperty&lt;T&gt;(AttachedProperty&lt;T&gt; prop) {<br>
            return (T)(_AttachedProperties[prop] ?? prop.DefaultValue);<br>
        }<br>
<br>
### Replacement extension methods:<br>
       public static void SetAttachedProperty&lt;T&gt;(this WindowlessControl c,<br>
AttachedProperty&lt;T&gt; prop, T val) {<br>
            c._AttachedProperties[prop] = val;<br>
        }<br>
<br>
        public static T GetAttachedProperty&lt;T&gt;(this WindowlessControl c,<br>
AttachedProperty&lt;T&gt; prop) {<br>
            return (T)(c._AttachedProperties[prop] ?? prop.DefaultValue);<br>
        }<br>
<br>
### Crash information:<br>
<br>
* Assertion at mini-generic-sharing.c:407, condition `!(*oti)-&gt;data&#39; not met<br>
<br>
        0   GenericTest                         0x000b98e6<br>
mono_handle_native_sigsegv + 422<br>
        1   libSystem.B.dylib                   0x94fc145b _sigtramp + 43<br>
        2   ???                                 0xffffffff 0x0 + 4294967295<br>
        3   libSystem.B.dylib                   0x9504e899 raise + 26<br>
        4   libSystem.B.dylib                   0x950649b8 abort + 93<br>
        5   GenericTest                         0x00256c41 monoeg_g_logv + 197<br>
        6   GenericTest                         0x00256ca3 monoeg_assertion_message<br>
+ 46<br>
        7   GenericTest                         0x000c3672<br>
rgctx_template_set_other_slot + 642<br>
        8   GenericTest                         0x000c47fd<br>
fill_in_rgctx_template_slot + 61<br>
        9   GenericTest                         0x000c488a<br>
fill_in_rgctx_template_slot + 202<br>
        10  GenericTest                         0x000c488a<br>
fill_in_rgctx_template_slot + 202<br>
        11  GenericTest                         0x000c488a<br>
fill_in_rgctx_template_slot + 202<br>
        12  GenericTest                         0x000c488a<br>
fill_in_rgctx_template_slot + 202<br>
        13  GenericTest                         0x000c4b15<br>
mono_method_lookup_or_register_other_info + 533<br>
        14  GenericTest                         0x00008162<br>
mono_resolve_patch_target + 1698<br>
        15  GenericTest                         0x000eba57 mono_arch_patch_code +<br>
87<br>
        16  GenericTest                         0x0000bae5 mono_codegen + 1269<br>
        17  GenericTest                         0x0000df37 mini_method_compile +<br>
8167<br>
        18  GenericTest                         0x0000fbd6<br>
mono_jit_compile_method_with_opt + 1574<br>
        19  GenericTest                         0x0001051a mono_jit_compile_method<br>
+ 42<br>
        20  GenericTest                         0x001bc07e mono_compile_method + 73<br>
        21  GenericTest                         0x000bb760 common_call_trampoline +<br>
512<br>
        22  ???                                 0x00425066 0x0 + 4345958<br>
        23  ???                                 0x056c8eca 0x0 + 91000522<br>
        24  ???                                 0x056c8e1f 0x0 + 91000351<br>
        25  ???                                 0x056c8d02 0x0 + 91000066<br>
        26  ???                                 0x056c6c88 0x0 + 90991752<br>
        27  ???                                 0x056c6c50 0x0 + 90991696<br>
        28  ???                                 0x056c4850 0x0 + 90982480<br>
        29  ???                                 0x056c45f4 0x0 + 90981876<br>
        30  ???                                 0x056c3560 0x0 + 90977632<br>
        31  ???                                 0x056c4598 0x0 + 90981784<br>
        32  ???                                 0x056c3135 0x0 + 90976565<br>
        33  GenericTest                         0x00010624 mono_jit_runtime_invoke<br>
+ 164<br>
        34  GenericTest                         0x001c1032 mono_runtime_invoke +<br>
137<br>
        35  GenericTest                         0x001c40f6<br>
mono_runtime_invoke_array + 1831<br>
        36  GenericTest                         0x00154f6f ves_icall_InternalInvoke<br>
+ 1163<br>
        37  ???                                 0x052a6de8 0x0 + 86666728<br>
        38  ???                                 0x052a6b98 0x0 + 86666136<br>
        39  ???                                 0x052a6a4b 0x0 + 86665803<br>
        40  ???                                 0x052a5ff4 0x0 + 86663156<br>
        41  ???                                 0x023d914c 0x0 + 37589324<br>
        42  mobjc-glue.dylib                    0x02a68dd5 Thunk + 37<br>
        43  libffi.dylib                        0x95857b9f ffi_closure_SYSV_inner +<br>
177<br>
        44  libffi.dylib                        0x958579c2 ffi_closure_SYSV + 34<br>
        45  AppKit                              0x96d6fcf8 -[NSWindow sendEvent:] +<br>
5693<br>
        46  AppKit                              0x96c88817 -[NSApplication<br>
sendEvent:] + 6431<br>
        47  AppKit                              0x96c1c2a7 -[NSApplication run] +<br>
917<br>
        48  AppKit                              0x96c142d9 NSApplicationMain + 574<br>
        49  ???                                 0x052b82b0 0x0 + 86737584<br>
        50  ???                                 0x052b81f8 0x0 + 86737400<br>
        51  ???                                 0x004aedf8 0x0 + 4910584<br>
        52  ???                                 0x004aeecf 0x0 + 4910799<br>
        53  GenericTest                         0x00010624 mono_jit_runtime_invoke<br>
+ 164<br>
        54  GenericTest                         0x001c1032 mono_runtime_invoke +<br>
137<br>
        55  GenericTest                         0x001c3940 mono_runtime_exec_main +<br>
669<br>
        56  GenericTest                         0x001c2c7a mono_runtime_run_main +<br>
843<br>
        57  GenericTest                         0x0008943d mono_main + 7773<br>
        58  GenericTest                         0x00002db5 start + 53<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://mono.1490590.n4.nabble.com/Generic-method-failing-at-mini-generic-sharing-c-407-condition-oti-data-not-met-tp3858093p3858093.html" target="_blank">http://mono.1490590.n4.nabble.com/Generic-method-failing-at-mini-generic-sharing-c-407-condition-oti-data-not-met-tp3858093p3858093.html</a><br>

Sent from the Mono - OSX mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Mono-osx mailing list<br>
<a href="mailto:Mono-osx@lists.ximian.com">Mono-osx@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-osx</a><br>
</font></blockquote></div><br></div>