[Mono-bugs] [Bug 78721][Nor] New - marshaling bug with LOGFONT (mono_marshal_free_asany)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jun 28 12:04:27 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 sebastien at ximian.com.

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

--- shadow/78721	2006-06-28 12:04:27.000000000 -0400
+++ shadow/78721.tmp.23952	2006-06-28 12:04:27.000000000 -0400
@@ -0,0 +1,109 @@
+Bug#: 78721
+Product: Mono: Runtime
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: interop
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: sebastien at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: marshaling bug with LOGFONT (mono_marshal_free_asany)
+
+Description of Problem:
+When freeing a LOGFONT mono_marshal_free_asany allocates a new string (not
+sure why) which can be invalid (and get trapped by valgrind).
+
+Steps to reproduce the problem:
+1. Compile this
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
+class LOGFONT {
+	public int lfHeight;
+	public int lfWidth;
+	public int lfEscapement;
+	public int lfOrientation;
+	public int lfWeight;
+	public byte lfItalic;
+	public byte lfUnderline;
+	public byte lfStrikeOut;
+	public byte lfCharSet;
+	public byte lfOutPrecision;
+	public byte lfClipPrecision;
+	public byte lfQuality;
+	public byte lfPitchAndFamily;
+	[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
+	public string lfFaceName;
+}
+
+class Program {
+
+	static void Main (string[] args)
+	{
+		Font f = new Font ("Arial", 12.5f);
+		if (args.Length > 0)
+			f.Dispose ();
+		LOGFONT	lf = new LOGFONT();
+		f.ToLogFont (lf);
+	}
+}
+
+2. and execute it under valgrind
+
+
+Actual Results (with some debug display)
+
+poupou at poupou:~/src> mcs logfont.cs -r:System.Drawing.dll
+poupou at poupou:~/src> mono logfont.exe
+
+** (logfont.exe:5519): WARNING **: GdipGetLogFontA font 0x82457f8 graphics
+0x82484e0 lf 0x82454b8
+
+** (logfont.exe:5519): WARNING **: not blittable
+
+** (logfont.exe:5519): WARNING **: mono_string_new: 'Arial' (len 5)
+poupou at poupou:~/src> mono logfont.exe 1
+
+** (logfont.exe:5525): WARNING **: GdipGetLogFontA font (nil) graphics
+0x8248df0 lf 0x8245480
+
+** (logfont.exe:5525): WARNING **: not blittable
+
+** (logfont.exe:5525): WARNING **: mono_string_new:
+'\x84\x9c%\u0008̢%\u0008\u000c\xa5%\u0008   *' (len 14)
+
+Unhandled Exception: System.ArgumentException: Invalid Parameter. A null
+reference or invalid value was found.
+  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000]
+  at System.Drawing.Font.ToLogFont (System.Object logFont,
+System.Drawing.Graphics graphics) [0x00000]
+  at System.Drawing.Font.ToLogFont (System.Object logFont) [0x00000]
+  at (wrapper remoting-invoke-with-check) System.Drawing.Font:ToLogFont
+(object)
+  at Program.Main (System.String[] args) [0x00000]
+
+
+Expected Results:
+No error in valgrind.
+
+How often does this happen? 
+When LOGFONT is marshaled in the GdipGetLogFont[A|W] calls - without being
+initialized.
+
+
+Additional Information:
+* When the font is disposed GdipGetLogFontA return an error which is turned
+into an exception in System.Drawing.
+* If I zeroize the string (in GdipGetLogFontA) then the error doesn't
+occurs. However I don't think this should be required (at least not in
+libgdiplus).


More information about the mono-bugs mailing list