[Mono-list] GdiPlus NullReferenceException
A Rafael D Teixeira
rafael.teixeirabr@terra.com.br
Fri, 18 Feb 2005 14:46:54 -0200
libgdiplus simply iniatilizes the needed fields and then mallocs enough
memory for the buffer and returns. Probably malloc is failling to return
the buffer, because it probably isn't thread-safe, and no guarding is
being done on it from what I could check in the sources bitmap.cs
(System.Drawing) and bitmap.c (libgdiplus).
Please post a bug at our bugzilla, for someone better acquainted to go
after it.
(http://bugzilla.ximian.com/enter_bug.cgi?product=Mono%3A+Class%20Libraries)
HIH,
On Wed, 2005-02-16 at 05:40, Yury Serdyuk wrote:
> Hi !
>
> NullReferenceException is thrown when trying to launch GDI application which
> uses a lot of threads :
>
>
> using System;
> using System.Threading;
> using System.Drawing;
>
> public class TestGDIPlus {
> public static void Main( string[] args ) {
> int nThreads = int.Parse( args [0] );
>
> for ( int i = 0; i < nThreads; i++ ) {
> Thread t = new Thread( new ThreadStart( TestGDIPlus.Run ) );
> t.Start();
> }
> }
>
> public static void Run() {
> Bitmap bmp = new Bitmap ( 1000, 1000,
> System.Drawing.Imaging.PixelFormat.Format32bppArgb );
> }
> }
>
> We run it as
>
>
> mono /path/to/TestGDIPlus.exe 8
>
>
> Actual Results:
> It throws this exception for each thread
>
> Unhandled Exception: System.NullReferenceException: Object reference not
> set to an instance of an object
> in (unmanaged) (wrapper managed-to-native)
> System.Drawing.GDIPlus:GdipCreateBitmapFromScan0
> (int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
> in <0x00004> (wrapper managed-to-native)
> System.Drawing.GDIPlus:GdipCreateBitmapFromScan0
> (int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
> in <0x00058> System.Drawing.Bitmap:.ctor
> (int,int,System.Drawing.Imaging.PixelFormat)
> in <0x0006f> (wrapper remoting-invoke-with-check)
> System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
> in <0x00036> TestGDIPlus:Run ()
> in <0x0005f> (wrapper delegate-invoke)
> System.MulticastDelegate:invoke_void ()
>
> or this one
> [serdyuk@itk-104 tmp]$ mono TestGDIPlus.exe 8
>
> Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
> in (unmanaged) System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
>
> This failure is occured only occasionally,
> so one needs to try run program multiply ones,
> as
>
> > [serdyuk@itk-104 tmp]$ mono TestGDIPlus.exe 8 [serdyuk@itk-104 tmp]$
> > mono TestGDIPlus.exe 8 [serdyuk@itk-104 tmp]$ mono TestGDIPlus.exe 8
> > [serdyuk@itk-104 tmp]$ mono TestGDIPlus.exe 8 [serdyuk@itk-104 tmp]$
> > mono TestGDIPlus.exe 8 Unhandled Exception:
> > System.NullReferenceException: Object reference not set to an instance
> > of an object in (unmanaged) System.Drawing.Bitmap:.ctor
> > (int,int,System.Drawing.Imaging.PixelFormat) [serdyuk@itk-104 tmp]$
>
>
> We have tested under Mono 1.0.5 ( libgdiplus-1.0.5 ) and
> Mono 1.1.3 ( libgdiplus-1.1.3 ) with the same result.
> We have used two diffrent glib-2.0 libraries -
>
> 2.2.1 and 2.4.7 .
>
> Please, help.
>
> Thanks.
>
> Yury Serdyuk.
>
>
>
>
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
> E-mail classificado pelo Identificador de Spam Inteligente Terra.
> Para alterar a categoria classificada, visite
> http://www.terra.com.br/centralunificada/emailprotegido/imail/imail.cgi?+_u=rafael.teixeirabr&_l=1,1108545090.367220.10824.lusaca.terra.com.br,5322,Des15,Des15
>
> Esta mensagem foi verificada pelo E-mail Protegido Terra.
> Scan engine: McAfee VirusScan / Atualizado em 09/02/2005 / Verso: 4.4.00 - Dat 4427
> Proteja o seu e-mail Terra: http://www.emailprotegido.terra.com.br/
--
Rafael "Monoman" Teixeira
Mono Hacker since 16 Jul 2001 - http://www.go-mono.org/
Mono Brasil Founding Member - http://monobrasil.redesolbrasil.org/
English Blog: http://monoblog.blogspot.com/
Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/