[Mono-bugs] [Bug 78741][Nor] New - Generic anon. delegates - runtime error.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jun 30 15:34:40 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jokri03 at samnet.sdu.dk.

http://bugzilla.ximian.com/show_bug.cgi?id=78741

--- shadow/78741	2006-06-30 15:34:40.000000000 -0400
+++ shadow/78741.tmp.22706	2006-06-30 15:34:40.000000000 -0400
@@ -0,0 +1,139 @@
+Bug#: 78741
+Product: Mono: Runtime
+Version: 1.1
+OS: other
+OS Details: CRUX Linux 2.2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: JIT
+AssignedTo: lupus at ximian.com                            
+ReportedBy: jokri03 at samnet.sdu.dk               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Generic anon. delegates - runtime error.
+
+I get a runtime error when trying to bind parameteres to methods using 
+generic anonymous delegates.
+
+Consider the following code:
+--------------------------------------------
+using System;
+
+namespace test {
+
+    public class Test {
+        public Test() {
+            Binders.Bound<bool> del;
+            del = Binders.Bind<bool,String>(Print, "Hello World");
+            del();
+        }
+
+        public bool Print(String input) {
+            Console.WriteLine(input);
+            return true;
+        }
+
+        public static void Main() {
+            new Test();
+        }
+    }
+
+    public class Binders {
+        public delegate T Bound<T>();
+        public delegate T Unary<T,A>(A a);
+        public static Bound<T> Bind<T,A>(Unary<T,A> Func, A a) {
+            return delegate () {
+                return Func<T>(a);
+            };
+        }
+    }
+}
+--------------------------------------------
+Insted of outputting "Hello World", it produces the following error:
+--------------------------------------------
+** ERROR **: file object.c: line 559 (compute_class_bitmap): should not 
+be reached
+aborting...
+
+=================================================================
+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.
+=================================================================
+
+Stacktrace:
+
+  at test.Test..ctor () <0xffffffff>
+  at test.Test..ctor () <0x00045>
+  at test.Test.Main () <0x00016>
+  at (wrapper runtime-invoke) System.Object.runtime_invoke_void 
+(object,intptr,intptr,intptr) <0xffffffff>
+
+Native stacktrace:
+
+        mono(mono_handle_native_sigsegv+0xc7) [0x815d807]
+        [0xffffe440]
+        /lib/libc.so.6(abort+0xeb) [0xb7da28fb]
+        /usr/lib/libglib-2.0.so.0(g_logv+0x485) [0xb7f18365]
+        /usr/lib/libglib-2.0.so.0(g_log+0x29) [0xb7f18399]
+        /usr/lib/libglib-2.0.so.0(g_assert_warning+0x72) [0xb7f18412]
+        mono [0x80d6dfd]
+        mono [0x80d6fc7]
+        mono(mono_class_vtable+0xce) [0x80d7cbe]
+        mono [0x812de9e]
+        mono [0x81413cf]
+        mono [0x8146e3b]
+        mono [0x81487df]
+        mono(mono_magic_trampoline+0x1a) [0x807d2ca]
+        [0xb7d68032]
+        [0xb75f9aff]
+        [0xb75f9a6e]
+        mono(mono_runtime_exec_main+0x60) [0x80d92a0]
+        mono(mono_runtime_run_main+0x171) [0x80dc9c1]
+        mono(mono_main+0x102a) [0x805d3ca]
+        /lib/libc.so.6(__libc_start_main+0xd0) [0xb7d8de00]
+        mono [0x805be21]
+Aborted
+--------------------------------------------
+If I rewrite the code to not use generics as shown below everything works 
+as expected.
+--------------------------------------------
+using System;
+
+namespace test {
+
+    public class Test {
+        public Test() {
+            Binders.Bound del;
+            del = Binders.Bind(Print, "Hello World");
+            del();
+        }
+
+        public bool Print(String input) {
+            Console.WriteLine(input);
+            return true;
+        }
+
+        public static void Main() {
+            new Test();
+        }
+    }
+
+    public class Binders {
+        public delegate bool Bound();
+        public delegate bool Unary(String a);
+        public static Bound Bind(Unary Func, String a) {
+            return delegate () {
+                return Func(a);
+            };
+        }
+    }
+}
+--------------------------------------------
+
+The sample code is compiled using gmcs, mono version 1.1.15.20060630, 
+since both 1.1.15 and 1.1.13.8 aren't able to compile the code.


More information about the mono-bugs mailing list