[Mono-bugs] [Bug 70589][Nor] New - bad free() marshalling a ref struct (?)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 15 Dec 2004 15:23:25 -0500 (EST)


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 danw@novell.com.

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

--- shadow/70589	2004-12-15 15:23:25.000000000 -0500
+++ shadow/70589.tmp.12928	2004-12-15 15:23:25.000000000 -0500
@@ -0,0 +1,57 @@
+Bug#: 70589
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: JIT
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: danw@novell.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: bad free() marshalling a ref struct (?)
+
+This program hangs:
+
+  public class RefTest {
+  	public static void Main ()
+  	{
+  		Gtk.StockItem item = new Gtk.StockItem ();
+  		Gtk.StockManager.Lookup ("gtk-ok", ref item);
+  	}
+  }
+
+If I run with --trace, I see it wedged inside an exception constructor.
+
+Running mono under gdb gives:
+
+Program received signal SIGSEGV, Segmentation fault.
+[Switching to Thread 1082465200 (LWP 25899)]
+0x40169ded in _int_free () from /lib/tls/libc.so.6
+(gdb) where
+#0  0x40169ded in _int_free () from /lib/tls/libc.so.6
+#1  0x4016a22b in free () from /lib/tls/libc.so.6
+#2  0x40062b32 in g_free () from /opt/gnome/lib/libglib-2.0.so.0
+#3  0x080a6760 in mono_marshal_free (ptr=0x40c8117b) at marshal.c:6640
+#4  0x080a73bb in mono_struct_delete_old (klass=0x82706b8,
+    ptr=0x408517e8 "\213\211�@�2�@") at marshal.c:7115
+#5  0x404e965e in ?? ()
+
+
+It seems to be mistakenly trying to free a stack pointer.
+
+Gtk.StockManager.Lookup looks like this:
+
+  [DllImport("libgtk-win32-2.0-0.dll")]
+  static extern bool gtk_stock_lookup(string stock_id, ref Gtk.StockItem item);
+
+  public static bool Lookup(string stock_id, ref Gtk.StockItem item) {
+          bool raw_ret = gtk_stock_lookup(stock_id, ref item);
+          bool ret = raw_ret;
+          return ret;
+  }