[Mono-bugs] [Bug 73258][Wis] New - Segmentation violation in multithreaded mode

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 3 Mar 2005 02:19:11 -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 yury@serdyuk.botik.ru.

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

--- shadow/73258	2005-03-03 02:19:11.000000000 -0500
+++ shadow/73258.tmp.13829	2005-03-03 02:19:11.000000000 -0500
@@ -0,0 +1,361 @@
+Bug#: 73258
+Product: Mono: Class Libraries
+Version: 1.0
+OS: SuSE 8.0
+OS Details: Linux server 2.4.25bigmem #7 SMP Wed Dec 15 10:05:05 EET 2004 i686 i686 i386 GNU/Linux
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: Yury@serdyuk.botik.ru               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Segmentation violation in multithreaded mode
+
+Description of Problem:
+
+NullReferenceException is thrown when trying to launch GDI application 
+in multithreaded mode.
+
+Steps to reproduce the problem:
+
+1. mcs /r:System.Drawing TestGDIPlus.cs
+--8<-------------------------------------
+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 ( 10, 10,
+                  System.Drawing.Imaging.PixelFormat.Format32bppArgb );
+
+ }
+
+}
+--8<-------------------------------------
+
+2. mono TestGDIPlus.exe 8 
+ 
+
+Actual Results:
+
+It throws exceptions for each thread
+--8<-------------------------------------
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+
+
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+in (unmanaged) (nil)
+in <0x00004> (wrapper managed-to-native) 
+System.Drawing.GDIPlus:GdipCreateBitmapFromScan0 
+(int,int,int,System.Drawing.Imaging.PixelFormat,intptr,intptr&)
+in <0x0002e> System.Drawing.Bitmap:.ctor 
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0003f> (wrapper remoting-invoke-with-check) 
+System.Drawing.Bitmap:.ctor (int,int,System.Drawing.Imaging.PixelFormat)
+in <0x0002d> TestGDIPlus:Run ()
+in <0x00041> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void ()
+--8<-------------------------------------
+
+Expected Results:
+
+Should just finish creating objects and exit
+
+How often does this happen? 
+
+Not always, but very often.
+
+Additional Information:
+
+This is gdb log :
+--8<-------------------------------------
+[serdyuk@itk-104 tmp]$ gdb --command=./gdb_commands --args mono 
+TestGDIPlus.exe 8
+GNU gdb 6.3
+Copyright 2004 Free Software Foundation, Inc.
+GDB is free software, covered by the GNU General Public License, and you 
+are
+welcome to change it and/or distribute copies of it under certain 
+conditions.
+Type "show copying" to see the conditions.
+There is absolutely no warranty for GDB.  Type "show warranty" for details.
+This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db 
+library "/lib/libthread_db.so.1".
+
+[Thread debugging using libthread_db enabled]
+[New Thread 16384 (LWP 21720)]
+
+[1]+  Stopped                 gdb --command=./gdb_commands --args mono 
+TestGDIPlus.exe 8
+[serdyuk@itk-104 tmp]$ %
+gdb --command=./gdb_commands --args mono TestGDIPlus.exe 8
+[New Thread 32769 (LWP 21722)]
+[New Thread 16386 (LWP 21723)]
+[New Thread 32771 (LWP 21724)]
+[New Thread 49156 (LWP 21725)]
+[New Thread 65541 (LWP 21726)]
+[New Thread 81926 (LWP 21727)]
+[New Thread 98311 (LWP 21728)]
+[New Thread 114696 (LWP 21729)]
+[New Thread 131081 (LWP 21730)]
+[New Thread 147466 (LWP 21731)]
+
+Program received signal SIGSEGV, Segmentation fault.
+[Switching to Thread 81926 (LWP 21727)]
+0x00000000 in ?? ()
+(gdb) info threads
+  11 Thread 147466 (LWP 21731)  0x400d0985 in __pthread_sigsuspend ()
+   from /lib/i686/libpthread.so.0
+  10 Thread 131081 (LWP 21730)  0x400d0985 in __pthread_sigsuspend ()
+   from /lib/i686/libpthread.so.0
+  9 Thread 114696 (LWP 21729)  0x400d0985 in __pthread_sigsuspend ()
+   from /lib/i686/libpthread.so.0
+  8 Thread 98311 (LWP 21728)  0x00000000 in ?? ()
+* 7 Thread 81926 (LWP 21727)  0x00000000 in ?? ()
+  6 Thread 65541 (LWP 21726)  0x400d0985 in __pthread_sigsuspend ()
+   from /lib/i686/libpthread.so.0
+  5 Thread 49156 (LWP 21725)  0x400d0985 in __pthread_sigsuspend ()
+   from /lib/i686/libpthread.so.0
+  4 Thread 32771 (LWP 21724)  0x400d0985 in __pthread_sigsuspend ()
+   from /lib/i686/libpthread.so.0
+  3 Thread 16386 (LWP 21723)  0x400d4086 in nanosleep () 
+from /lib/i686/libpthread.so.0
+  2 Thread 32769 (LWP 21722)  0x40226357 in poll () 
+from /lib/i686/libc.so.6
+  1 Thread 16384 (LWP 21720)  0x400d4086 in nanosleep () 
+from /lib/i686/libpthread.so.0
+(gdb) thread apply all bt
+
+Thread 11 (Thread 147466 (LWP 21731)):
+#0  0x400d0985 in __pthread_sigsuspend () from /lib/i686/libpthread.so.0
+#1  0x400d0388 in __pthread_wait_for_restart_signal () 
+from /lib/i686/libpthread.so.0
+#2  0x400d1d38 in __pthread_lock () from /lib/i686/libpthread.so.0
+#3  0x400cedc6 in pthread_mutex_lock () from /lib/i686/libpthread.so.0
+#4  0x080c2443 in EnterCriticalSection (section=0x82446e4) at critical-
+sections.c:151
+#5  0x0807da29 in mono_runtime_class_init (vtable=0x81d4d68) at 
+object.c:233
+#6  0x080fff0b in mono_jit_compile_method_inner (method=0x40d0ea80, 
+target_domain=0x81b6f00)
+    at mini.c:9103
+#7  0x08100104 in mono_jit_compile_method (method=0x40d0ea80) at 
+mini.c:9140
+#8  0x0807dc00 in mono_compile_method (method=0x40d0ea80) at object.c:352
+#9  0x080ffd69 in mono_jit_compile_method_inner (method=0x40d02d20, 
+target_domain=0x81b6f00)
+    at mini.c:9037
+#10 0x08100104 in mono_jit_compile_method (method=0x40d02d20) at 
+mini.c:9140
+#11 0x0807dc00 in mono_compile_method (method=0x40d02d20) at object.c:352
+#12 0x0806af0e in x86_magic_trampoline (eax=1103130020, ecx=136553960, 
+edx=1087384864, esi=0,
+    edi=10, ebx=10, code=0x4067370f "\203´\030\213àVØ\026", m=0x40d02d20) 
+at tramp-x86.c:100
+#13 0x40016035 in ?? ()
+#14 0x41c06da4 in ?? ()
+#15 0x0823a5e8 in ?? ()
+#16 0x40d02d20 in ?? ()
+#17 0x00000000 in ?? ()
+---Type <return> to continue, or q <return> to quit---
+#18 0x0000000a in ?? ()
+#19 0x0000000a in ?? ()
+#20 0x4067370f in ?? ()
+#21 0x40d02d20 in ?? ()
+#22 0x0823a5e8 in ?? ()
+#23 0x0823a5d0 in ?? ()
+#24 0x40d02d20 in ?? ()
+#25 0x0000000a in ?? ()
+#26 0x0000000a in ?? ()
+#27 0x00000000 in ?? ()
+#28 0x41c06dac in ?? ()
+#29 0x4067370f in ?? ()
+#30 0x081c2ee8 in ?? ()
+#31 0x41c06da4 in ?? ()
+#32 0x0823a5e8 in ?? ()
+#33 0x40d02d20 in ?? ()
+#34 0x4067370f in ?? ()
+#35 0x0000000a in ?? ()
+#36 0x0000000a in ?? ()
+#37 0x00000000 in ?? ()
+#38 0x0026200a in ?? ()
+#39 0x00000000 in ?? ()
+#40 0x41c06da4 in ?? ()
+---Type <return> to continue, or q <return> to quit---
+#41 0x00000000 in ?? ()
+#42 0x081c2ee8 in ?? ()
+#43 0x41c06dd4 in ?? ()
+#44 0x40673670 in ?? ()
+#45 0x081c2ee8 in ?? ()
+#46 0x0000000a in ?? ()
+#47 0x0000000a in ?? ()
+#48 0x0026200a in ?? ()
+#49 0x0026200a in ?? ()
+#50 0x081c2ee8 in ?? ()
+#51 0x081c0e10 in ?? ()
+#52 0x41c06e34 in ?? ()
+#53 0x41c06df4 in ?? ()
+#54 0x406735be in ?? ()
+#55 0x081c2ee8 in ?? ()
+#56 0x0000000a in ?? ()
+#57 0x0000000a in ?? ()
+#58 0x0026200a in ?? ()
+#59 0x00000000 in ?? ()
+#60 0x00000000 in ?? ()
+#61 0x41c06e04 in ?? ()
+#62 0x40673412 in ?? ()
+#63 0x081b6780 in ?? ()
+---Type <return> to continue, or q <return> to quit---
+#64 0x0823ac40 in ?? ()
+#65 0x41c06e44 in ?? ()
+#66 0x0809d7fa in start_wrapper (data=0xa) at threads.c:292
+Previous frame inner to this frame (corrupt stack?)
+#0  0x00000000 in ?? ()
+(gdb) q
+The program is running.  Exit anyway? (y or n) y
+[serdyuk@itk-104 tmp]
+--8<-------------------------------------
+
+Mono version :
+
+Mono JIT compiler version 1.1.4, (C) 2002-2004 Novell, Inc and 
+Contributors. www.go-mono.com
+        TLS:           __thread
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV      : normal
+        Globalization: none
+[serdyuk@itk-104 serdyuk]$
+
+libgdiplus version :
+
+release 41000 from svn
+
+gdb_commands file :
+
+handle SIGPWR  nostop
+handle SIGXCPU nostop
+handle SIGTTOU nostop
+
+r