[Mono-bugs] [Bug 79898][Nor] New - Region instance can get collected by GC before being re-created

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Nov 10 17:45:58 EST 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=79898

--- shadow/79898	2006-11-10 17:45:58.000000000 -0500
+++ shadow/79898.tmp.18724	2006-11-10 17:45:58.000000000 -0500
@@ -0,0 +1,192 @@
+Bug#: 79898
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: sebastien at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Region instance can get collected by GC before being re-created
+
+Description of Problem:
+
+from XplatUIX11.cs around line 3657
+
+Rectangle rect = new Rectangle (xevent.ExposeEvent.x, xevent.ExposeEvent.y,
+xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+Region region = new Region (rect);
+IntPtr hrgn = region.GetHrgn (null); // Graphics object isn't needed
+msg.message = Msg.WM_NCPAINT;
+msg.wParam = hrgn == IntPtr.Zero ? (IntPtr)1 : hrgn;
+break;
+
+from InternalWindowManager.cs around line 243
+
+if (m.WParam.ToInt32 () > 1) {
+	Region r = Region.FromHrgn (m.WParam);
+
+
+Steps to reproduce the problem:
+1. run sample from #79883
+2. wait
+3. resize window
+4. loop to 2 until forever (minus a few seconds)
+
+
+Actual Results:
+1. Region region is created, used and "forgotten" (no reference).
+2. The GC collects the region instance. The pointer becomes invalid.
+3. InternalWindowManager recreates the region from the (invalid) pointer.
+4. Crash
+
+Expected Results:
+No crash
+
+How often does this happen? 
+When the GC does its job at a bad time
+
+Additional Information:
+
+=================================================================
+Got a SIGSEGV while executing native code. This usually indicates
+a fatal error in the mono runtime or one of the native libraries
+used by your application.
+=================================================================
+
+Stacktrace:
+
+  at (wrapper managed-to-native)
+System.Drawing.GDIPlus.GdipCreateRegionHrgn (intptr,intptr&) <0x00004>
+  at (wrapper managed-to-native)
+System.Drawing.GDIPlus.GdipCreateRegionHrgn (intptr,intptr&) <0xffffffff>
+  at System.Drawing.Region.FromHrgn (intptr) [0x00016] in
+/home/poupou/svn/mcs/class/System.Drawing/System.Drawing/Region.cs:523
+  at System.Windows.Forms.InternalWindowManager.HandleMessage
+(System.Windows.Forms.Message&) [0x00348] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs:244
+  at System.Windows.Forms.Form.WndProc (System.Windows.Forms.Message&)
+[0x0002f] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:1744
+  at ControlNativeWindow.WndProc (System.Windows.Forms.Message&) [0x00000]
+in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:181
+  at System.Windows.Forms.NativeWindow.WndProc
+(intptr,System.Windows.Forms.Msg,intptr,intptr) [0x0006b] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:159
+  at System.Windows.Forms.XplatUIX11.DispatchMessage
+(System.Windows.Forms.MSG&) [0x00000] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:2851
+  at System.Windows.Forms.XplatUI.DispatchMessage
+(System.Windows.Forms.MSG&) [0x00000] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs:428
+  at System.Windows.Forms.Application.DispatchMessage
+(System.Windows.Forms.MSG&) [0x00000] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:447
+  at System.Windows.Forms.Application.RunLoop
+(bool,System.Windows.Forms.ApplicationContext) [0x00269] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:572
+  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form)
+[0x00000] in
+/home/poupou/svn/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:437
+  at MDI.MDI.Main () <0x0001f>
+  at (wrapper runtime-invoke) System.Object.runtime_invoke_void
+(object,intptr,intptr,intptr) <0xffffffff>
+
+Native stacktrace:
+
+        mono(mono_handle_native_sigsegv+0xde) [0x8165e2e]
+        mono [0x8130a58]
+        [0xffffe440]
+        /usr/local/lib/libgdiplus.so(gdip_copy_region+0x8f) [0xb6c2e90f]
+        /usr/local/lib/libgdiplus.so(GdipCloneRegion+0x4b) [0xb6c2e99b]
+        /usr/local/lib/libgdiplus.so(GdipCreateRegionHrgn+0x2c) [0xb6c2e9ec]
+        [0xb5fbc979]
+        [0xb5fbc8c2]
+        [0xb60cab16]
+        [0xb61d82eb]
+        [0xb62920d5]
+        [0xb6291fa3]
+        [0xb62763cf]
+        [0xb62763ae]
+        [0xb627635e]
+        [0xb61b0d03]
+        [0xb61b01cd]
+        [0xb7506748]
+        [0xb75057be]
+        mono(mono_runtime_exec_main+0x62) [0x80e1ea2]
+        mono(mono_runtime_run_main+0x1b9) [0x80e2189]
+        mono(mono_main+0xe40) [0x805ecd0]
+        mono [0x805d9a2]
+        /lib/libc.so.6(__libc_start_main+0xdc) [0xb7d9787c]
+        mono [0x805d8f1]
+
+Debug info from gdb:
+
+Using host libthread_db library "/lib/libthread_db.so.1".
+[Thread debugging using libthread_db enabled]
+[New Thread -1210574528 (LWP 1124)]
+[New Thread -1219478624 (LWP 1126)]
+[New Thread -1219396704 (LWP 1125)]
+0xffffe410 in __kernel_vsyscall ()
+  3 Thread -1219396704 (LWP 1125)  0xffffe410 in __kernel_vsyscall ()
+  2 Thread -1219478624 (LWP 1126)  0xffffe410 in __kernel_vsyscall ()
+  1 Thread -1210574528 (LWP 1124)  0xffffe410 in __kernel_vsyscall ()
+
+Thread 3 (Thread -1219396704 (LWP 1125)):
+#0  0xffffe410 in __kernel_vsyscall ()
+#1  0xb7ed3a46 in __nanosleep_nocancel () from /lib/libpthread.so.0
+#2  0x08108d44 in collection_thread (unused=0x0) at collection.c:34
+#3  0xb7ecd2ab in start_thread () from /lib/libpthread.so.0
+#4  0xb7e3f75e in clone () from /lib/libc.so.6
+
+Thread 2 (Thread -1219478624 (LWP 1126)):
+#0  0xffffe410 in __kernel_vsyscall ()
+#1  0xb7ed0726 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
+#2  0x0811309f in timedwait_signal_poll_cond (cond=0xb79ed1dc,
+    mutex=0xb79ed1c4, timeout=0x0, alertable=0) at handles.c:1409
+#3  0x0811585f in _wapi_handle_timedwait_signal_handle (handle=0x404,
+    timeout=0x0, alertable=0) at handles.c:1489
+#4  0x081158dc in _wapi_handle_wait_signal_handle (handle=0x404, alertable=0)
+    at handles.c:1449
+#5  0x081165ef in WaitForSingleObjectEx (handle=0x404, timeout=4294967295,
+    alertable=0) at wait.c:200
+#6  0x0816cb2a in finalizer_thread (unused=0x0) at gc.c:816
+#7  0x080bcab4 in start_wrapper (data=0x8214558) at threads.c:313
+#8  0x0810d29e in thread_start_routine (args=0xb78a0508) at threads.c:253
+#9  0x08126ad5 in GC_start_routine (arg=0x22f40) at pthread_support.c:1357
+#10 0xb7ecd2ab in start_thread () from /lib/libpthread.so.0
+#11 0xb7e3f75e in clone () from /lib/libc.so.6
+
+Thread 1 (Thread -1210574528 (LWP 1124)):
+#0  0xffffe410 in __kernel_vsyscall ()
+#1  0xb7e38e11 in ___newselect_nocancel () from /lib/libc.so.6
+#2  0xb7f2e9a0 in g_spawn_sync () from /opt/gnome/lib/libglib-2.0.so.0
+#3  0xb7f2ed6c in g_spawn_command_line_sync ()
+   from /opt/gnome/lib/libglib-2.0.so.0
+#4  0x08165ec0 in mono_handle_native_sigsegv (signal=11, ctx=0xbfce7a6c)
+    at mini-exceptions.c:1072
+#5  0x08130a58 in sigsegv_signal_handler (_dummy=11, info=0xbfce79ec,
+    context=0xbfce7a6c) at mini.c:10826
+#6  <signal handler called>
+#7  gdip_region_bitmap_clone (bitmap=0x18) at region-bitmap.c:292
+#8  0xb6c2e90f in gdip_copy_region (source=0x858b860, dest=0x85901c0)
+    at region.c:288
+#9  0xb6c2e99b in GdipCloneRegion (region=0x858b860, cloneRegion=0xbfce7e30)
+    at region.c:472
+#10 0xb6c2e9ec in GdipCreateRegionHrgn (hRgn=0xb7ea014c, region=0x18)
+    at region.c:1726
+#11 0xb5fbc979 in ?? ()
+#12 0x0858b860 in ?? ()
+#13 0xbfce7e30 in ?? ()
+#14 0x00000000 in ?? ()
+#0  0xffffe410 in __kernel_vsyscall ()
+
+Aborted


More information about the mono-bugs mailing list