[Mono-bugs] [Bug 52217][Wis] New - NullReference exception thrown randomly in GDI+ code

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 28 Apr 2004 20:12:51 -0400 (EDT)


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 miguel@ximian.com.

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

--- shadow/52217	2004-04-28 20:12:51.000000000 -0400
+++ shadow/52217.tmp.14383	2004-04-28 20:12:51.000000000 -0400
@@ -0,0 +1,181 @@
+Bug#: 52217
+Product: Mono: Class Libraries
+Version: unspecified
+OS: unknown
+OS Details: Mandrake 9.2
+Status: RESOLVED   
+Resolution: FIXED
+Severity: Unknown
+Priority: Wishlist
+Component: Sys.Drawing.
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: cmello@gmx.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: NullReference exception thrown randomly in GDI+ code
+
+Description of Problem: When I try to save a bitmap to a stream, the
+following exception is thrown:
+
+
+System.TypeInitializationException: An exception was thrown by the type
+initializer for System.Drawing.GDIPlus ---> System.MissingMethodException:
+A missing method exception has occurred.
+in <0x00042> (wrapper managed-to-native)
+System.Drawing.GDIPlus:GdiplusStartup
+(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
+in [0x00015] (at
+/tmp/snapshot/20031214/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:34)
+System.Drawing.GDIPlus:.cctor ()
+--- End of inner exception stack trace ---
+
+in (unmanaged) System.Drawing.GDIPlus:GdipCreateBitmapFromScan0
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,int&)
+in [0x0004c] (at
+/tmp/snapshot/20031214/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:58)
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in [0x00008] (at
+/tmp/snapshot/20031214/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:33)
+System.Drawing.Bitmap:.ctor (int,int)
+in <0x00061> (wrapper remoting-invoke-with-check)
+System.Drawing.Bitmap:.ctor (int,int)
+in <0x0006d> teste2.WebForm2:Page_Load (object,System.EventArgs)
+in <0x0005a> (wrapper delegate-invoke)
+System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)
+in [0x00030] (at
+/tmp/snapshot/20031214/mcs/class/System.Web/System.Web.UI/Control.cs:545)
+System.Web.UI.Control:OnLoad (System.EventArgs)
+in [0x00006] (at
+/tmp/snapshot/20031214/mcs/class/System.Web/System.Web.UI/Control.cs:778)
+System.Web.UI.Control:LoadRecursive ()
+in [0x0002d] (at
+/tmp/snapshot/20031214/mcs/class/System.Web/System.Web.UI/Page.cs:671)
+System.Web.UI.Page:InternalProcessRequest ()
+in [0x0002a] (at
+/tmp/snapshot/20031214/mcs/class/System.Web/System.Web.UI/Page.cs:655)
+System.Web.UI.Page:ProcessRequest (System.Web.HttpContext)
+in [0x00094] (at
+/tmp/snapshot/20031214/mcs/class/System.Web/System.Web/HttpApplication.cs:405)
+.ExecuteHandlerState:Execute ()
+in [0x0001e] (at
+/tmp/snapshot/20031214/mcs/class/System.Web/System.Web/HttpApplication.cs:669)
+.StateMachine:ExecuteState 
+
+Attached a sample asp.net page that creates a GIF image dynamically. It
+works under MS .NET 1.1 but results in the stack trace shown above.
+
+Expected Results: A dynamic GIF with a circle should be generated.
+
+
+How often does this happen? 
+Always
+
+------- Additional Comments From cmello@gmx.net  2003-12-15 22:40 -------
+Created an attachment (id=6246)
+Sample code that reproduces the bug
+
+
+------- Additional Comments From gonzalo@ximian.com  2003-12-16 10:59 -------
+First i did make clean && make && make install in
+mcs/class/System.Drawing. Then try the attachment...
+
+------- Additional Comments From gonzalo@ximian.com  2003-12-16 11:00 -------
+Created an attachment (id=6259)
+Non-ASPNET test
+
+
+------- Additional Comments From gonzalo@ximian.com  2003-12-16 11:01 -------
+OOps. Replace ".gif" by ".png". Anyway, the file produced is a Png.
+Attached.
+
+------- Additional Comments From gonzalo@ximian.com  2003-12-16 11:01 -------
+Created an attachment (id=6260)
+Result
+
+
+------- Additional Comments From gonzalo@ximian.com  2003-12-16 11:03 -------
+So the problem was that there's no output Gif encoder.
+That depends on cairo.
+
+
+------- Additional Comments From cmello@gmx.net  2003-12-20 15:25 -------
+I compiled the latest Cairo version and the standalone program
+attached by Gonzalo worked perfectly. But it didn't work consistently
+from the asp.net sample (even changing to PNG format); it works most
+of the times, but in others the image isn't generated. 
+
+Now I don't know if the problem is in System.Drawing or System.Web..
+Please edit the case and set it accordingly.
+
+I am using XSP-0.8. 
+
+------- Additional Comments From cmello@gmx.net  2003-12-21 08:02 -------
+I could reproduce the bug in the standalone program! I changed it so
+that the image is generated inside a loop. I guess this is  exactly
+what happens in the asp.net page, when several requests are handled.
+
+This is the stack trace:
+
+System.NullReferenceException: A null value was found where an object
+instance was required
+in (unmanaged) (wrapper managed-to-native)
+System.Drawing.GDIPlus:GdipDrawLineI (intptr,intptr,int,int,int,int)
+in <0x00004> (wrapper managed-to-native)
+System.Drawing.GDIPlus:GdipDrawLineI (intptr,intptr,int,int,int,int)
+in [0x00012] (at
+/home/cesar/cvs-mono2/mcs/class/System.Drawing/System.Drawing/Graphics.cs:478)
+System.Drawing.Graphics:DrawLine (System.Drawing.Pen,int,int,int,int)
+in <0x00097> (wrapper remoting-invoke-with-check)
+System.Drawing.Graphics:DrawLine (System.Drawing.Pen,int,int,int,int)
+in <0x001f3> teste2.WebForm2:Page_Load (object,System.EventArgs)
+in <0x0005a> (wrapper delegate-invoke)
+System.MulticastDelegate:invoke_void_object_EventArgs
+(object,System.EventArgs)
+in [0x00030] (at
+/tmp/snapshot/20031217/mcs/class/System.Web/System.Web.UI/Control.cs:545)
+System.Web.UI.Control:OnLoad (System.EventArgs)
+in [0x00006] (at
+/tmp/snapshot/20031217/mcs/class/System.Web/System.Web.UI/Control.cs:778)
+System.Web.UI.Control:LoadRecursive ()
+in [0x0002d] (at
+/tmp/snapshot/20031217/mcs/class/System.Web/System.Web.UI/Page.cs:668)
+System.Web.UI.Page:InternalProcessRequest ()
+in [0x0002a] (at
+/tmp/snapshot/20031217/mcs/class/System.Web/System.Web.UI/Page.cs:652)
+System.Web.UI.Page:ProcessRequest (System.Web.HttpContext)
+in [0x00094] (at
+/tmp/snapshot/20031217/mcs/class/System.Web/System.Web/HttpApplication.cs:405)
+.ExecuteHandlerState:Execute ()
+in [0x0001e] (at
+/tmp/snapshot/20031217/mcs/class/System.Web/System.Web/HttpApplication.cs:669)
+.StateMachine:ExecuteState (System.Web.HttpApplic
+
+So definetly this is a System.Drawing bug.
+
+------- Additional Comments From cmello@gmx.net  2003-12-21 08:04 -------
+Created an attachment (id=6288)
+Attachment to reproduce the bug in non-asp code
+
+
+------- Additional Comments From duncan@ximian.com  2003-12-21 08:34 -------
+An observation:
+
+I noticed a similar bug when I was working on the DrawArc
+implementation this afternoon: When I run my test app repeatedly, with
+very little break in between each invocation, I see the same
+NullReference crash. After a few more tries, the crash goes away
+temporarily. Try again, and you see the crash once more.
+
+That behavior is probably related to this bug, as removing the outer
+loop eliminates the crash, though no reliably.
+
+I started printing out the loop number (i) in the first
+Console.WriteLine. I noticed that while the crash often occurs in the
+first iteration, sometimes it also occurs in the second iteration,
+being that the first iteration was successful.
+
+Could this be a Cairo bug?
+
+------- Additional Comments From miguel@ximian.com  2004-04-28 20:12 -------
+This has been fixed now.