[Mono-bugs] [Bug 78759][Nor] New - [PATCH] ImageListStreamer fails to load image resources

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jul 4 05:21:46 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 atsushi at ximian.com.

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

--- shadow/78759	2006-07-04 05:21:46.000000000 -0400
+++ shadow/78759.tmp.20810	2006-07-04 05:21:46.000000000 -0400
@@ -0,0 +1,224 @@
+Bug#: 78759
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [PATCH] ImageListStreamer fails to load image resources
+
+This problem appears somehow only on Win32, as it seems our Bitmap loader
+check is less strict than that of Windows GDI+.
+
+The attached example resx file cannot be compiled with our MWF. Our resgen
+when run under .NET runtime it did not fail.
+
+I modified monoresgen.cs to not catch exceptions, and the error was like
+[1] below (it is from ReportBuilder that Carlos ported).
+
+I dug the problem in depth and found that 
+
+  - base64 decoding is working fine, as long as I tested with [2] (both MS
+and Mono resulted in the same binary).
+  - ImageListStreamer saves two different bitmaps, body image(s) and the
+corresponding mask. The error happens when it saves this mask bitmap.
+
+Seems like ImageListStreamer deserializer exceeds to read body, and there
+also seems another extra data between the body and the mask. It matched the
+actual size of the bitmap (here "size" means, Width x Height).
+
+I'm attaching a possible fix that is based on all assumptions above,
+leaving some commented code that I used for examining this issue.
+
+
+[1]
+
+$ mono --debug ../../../svn/mcs/class/lib/default/resgen.exe base64.resx
+
+Unhandled Exception: System.Reflection.TargetInvocationException: Exception has
+been thrown by the target of an invocation. --->
+System.Reflection.TargetInvocat
+ionException: Exception has been thrown by the target of an invocation.
+---> Sys
+tem.ArgumentException: Invalid Parameter. A null reference or invalid value was
+found.
+  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x0006d] in
+C:\cygwin\h
+ome\atsushi\svn\mcs\class\System.Drawing\System.Drawing\gdipFunctions.cs:178
+  at System.Drawing.Image.InitFromStream (System.IO.Stream stream) [0x000d3] in
+C:\cygwin\home\atsushi\svn\mcs\class\System.Drawing\System.Drawing\Image.cs:265
+
+  at System.Drawing.Bitmap..ctor (System.IO.Stream stream, Boolean useIcm)
+[0x00
+018] in
+C:\cygwin\home\atsushi\svn\mcs\class\System.Drawing\System.Drawing\Bitma
+p.cs:105
+  at System.Drawing.Bitmap..ctor (System.IO.Stream stream) [0x00000] in
+C:\cygwi
+n\home\atsushi\svn\mcs\class\System.Drawing\System.Drawing\Bitmap.cs:83
+  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor
+(System.IO
+.Stream)
+  at System.Windows.Forms.ImageListStreamer..ctor
+(System.Runtime.Serialization.
+SerializationInfo info, StreamingContext context) [0x00149] in
+C:\cygwin\home\at
+sushi\svn\mcs\class\Managed.Windows.Forms\System.Windows.Forms\ImageListStreamer
+.cs:98
+  at <0x00000> <unknown method>
+  at (wrapper managed-to-native)
+System.Reflection.MonoCMethod:InternalInvoke (o
+bject,object[])
+  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags
+invok
+eAttr, System.Reflection.Binder binder, System.Object[] parameters,
+System.Globa
+lization.CultureInfo culture) [0x00040] in
+C:\cygwin\home\atsushi\svn\mcs\class\
+corlib\System.Reflection\MonoMethod.cs:346 --- End of inner exception stack
+trac
+e ---
+
+  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags
+invok
+eAttr, System.Reflection.Binder binder, System.Object[] parameters,
+System.Globa
+lization.CultureInfo culture) [0x00065] in
+C:\cygwin\home\atsushi\svn\mcs\class\
+corlib\System.Reflection\MonoMethod.cs:352
+  at System.Reflection.MethodBase.Invoke (System.Object obj,
+System.Object[] par
+ameters) [0x00000] in
+C:\cygwin\home\atsushi\svn\mcs\class\corlib\System.Reflect
+ion\MethodBase.cs:86
+  at System.Runtime.Serialization.ObjectRecord.LoadData
+(System.Runtime.Serializ
+ation.ObjectManager manager, ISurrogateSelector selector, StreamingContext
+conte
+xt) [0x000da] in
+C:\cygwin\home\atsushi\svn\mcs\class\corlib\System.Runtime.Seri
+alization\ObjectManager.cs:541
+  at System.Runtime.Serialization.ObjectManager.DoFixups () [0x00069] in
+C:\cygw
+in\home\atsushi\svn\mcs\class\corlib\System.Runtime.Serialization\ObjectManager.
+cs:78
+  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject
+(System.IO.BinaryReader reader) [0x0000f] in
+C:\cygwin\home\atsushi\svn\mcs\clas
+s\corlib\System.Runtime.Serialization.Formatters.Binary\ObjectReader.cs:115
+  at
+System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph
+ (System.IO.BinaryReader reader, Boolean readHeaders, System.Object result,
+Syst
+em.Runtime.Remoting.Messaging.Header[] headers) [0x00044] in
+C:\cygwin\home\atsu
+shi\svn\mcs\class\corlib\System.Runtime.Serialization.Formatters.Binary\ObjectRe
+ader.cs:105
+  at
+System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeser
+ialize (System.IO.Stream serializationStream,
+System.Runtime.Remoting.Messaging.
+HeaderHandler handler) [0x00079] in
+C:\cygwin\home\atsushi\svn\mcs\class\corlib\
+System.Runtime.Serialization.Formatters.Binary\BinaryFormatter.cs:172
+  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
+(System.IO.Stream serializationStream) [0x00000] in
+C:\cygwin\home\atsushi\svn\m
+cs\class\corlib\System.Runtime.Serialization.Formatters.Binary\BinaryFormatter.c
+s:129
+  at System.Resources.ResXResourceReader.load_data () [0x0015d] in
+C:\cygwin\hom
+e\atsushi\svn\mcs\class\Managed.Windows.Forms\System.Resources\ResXResourceReade
+r.cs:229
+  at System.Resources.ResXResourceReader.basic_setup () [0x00032] in
+C:\cygwin\h
+ome\atsushi\svn\mcs\class\Managed.Windows.Forms\System.Resources\ResXResourceRea
+der.cs:104
+  at System.Resources.ResXResourceReader..ctor (System.IO.Stream stream)
+[0x0003
+5] in
+C:\cygwin\home\atsushi\svn\mcs\class\Managed.Windows.Forms\System.Resource
+s\ResXResourceReader.cs:62
+  at <0x00000> <unknown method>
+  at (wrapper managed-to-native)
+System.Reflection.MonoCMethod:InternalInvoke (o
+bject,object[])
+  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags
+invok
+eAttr, System.Reflection.Binder binder, System.Object[] parameters,
+System.Globa
+lization.CultureInfo culture) [0x00040] in
+C:\cygwin\home\atsushi\svn\mcs\class\
+corlib\System.Reflection\MonoMethod.cs:346 --- End of inner exception stack
+trac
+e ---
+
+  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags
+invok
+eAttr, System.Reflection.Binder binder, System.Object[] parameters,
+System.Globa
+lization.CultureInfo culture) [0x00065] in
+C:\cygwin\home\atsushi\svn\mcs\class\
+corlib\System.Reflection\MonoMethod.cs:352
+  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr,
+System.Refle
+ction.Binder binder, System.Object[] parameters,
+System.Globalization.CultureInf
+o culture) [0x00000] in
+C:\cygwin\home\atsushi\svn\mcs\class\corlib\System.Refle
+ction\MonoMethod.cs:357
+  at System.Activator.CreateInstance (System.Type type, BindingFlags
+bindingAttr
+, System.Reflection.Binder binder, System.Object[] args,
+System.Globalization.Cu
+ltureInfo culture, System.Object[] activationAttributes) [0x00123] in
+C:\cygwin\
+home\atsushi\svn\mcs\class\corlib\System\Activator.cs:226
+  at System.Activator.CreateInstance (System.Type type, System.Object[]
+args, Sy
+stem.Object[] activationAttributes) [0x00000] in
+C:\cygwin\home\atsushi\svn\mcs\
+class\corlib\System\Activator.cs:171
+  at System.Activator.CreateInstance (System.Type type, System.Object[]
+args) [0
+x00000] in C:\cygwin\home\atsushi\svn\mcs\class\corlib\System\Activator.cs:166
+  at ResGen.GetReader (System.IO.Stream stream, System.String name)
+[0x00070] in
+ C:\cygwin\home\atsushi\svn\mcs\tools\resgen\monoresgen.cs:70
+  at ResGen.CompileResourceFile (System.String sname, System.String dname)
+[0x00
+009] in C:\cygwin\home\atsushi\svn\mcs\tools\resgen\monoresgen.cs:102
+  at ResGen.Main (System.String[] args) [0x0015e] in
+C:\cygwin\home\atsushi\svn\
+mcs\tools\resgen\monoresgen.cs:173
+
+[2]
+//
+// run: mono blah.exe base64.xml /root/data/value
+//
+using System;
+using System.IO;
+using System.Xml;
+
+public class Test
+{
+	public static void Main (string [] args)
+	{
+		XmlDocument doc = new XmlDocument ();
+		doc.Load (args [0]);
+		string b64 = doc.SelectSingleNode (args [1]).InnerText;
+		byte [] bin = Convert.FromBase64String (b64);
+		Stream f = File.Create ("base64.bin");
+		f.Write (bin, 0, bin.Length);
+		f.Close ();
+	}
+}


More information about the mono-bugs mailing list