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

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 18 Dec 2004 09:59:29 -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 vargaz@gmail.com.

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

--- shadow/70589	2004-12-15 15:23:25.000000000 -0500
+++ shadow/70589.tmp.15710	2004-12-18 09:59:29.000000000 -0500
@@ -1,14 +1,14 @@
 Bug#: 70589
 Product: Mono: Runtime
 Version: 1.1
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: JIT
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: danw@novell.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
@@ -52,6 +52,17 @@
 
   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;
   }
+
+------- Additional Comments From vargaz@gmail.com  2004-12-18 09:59 -------
+I think the problem here is that the runtime attemps to free the
+members of the structure returned by gtk_stock_lookup, and one of string
+members is not dynamically allocated, but points to static memory,
+causing the crash. The solution would be to declare those members as
+IntPtr, not string, and marshal their contents manually. Also,
+looking at the documentation of gtk_stock_lookup, it seems like the
+managed prototype should use 'out' instead of 'ref'. This means the
+runtime does not have to copy the contents of the managed structure to
+the unmanaged structure, speeding things up.