[Mono-bugs] [Bug 77790][Wis] New - OS X/i386: Problem with GC on non-main thread

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Mar 14 22:16:31 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 bryan at imeem.com.

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

--- shadow/77790	2006-03-14 22:16:31.000000000 -0500
+++ shadow/77790.tmp.10899	2006-03-14 22:16:31.000000000 -0500
@@ -0,0 +1,183 @@
+Bug#: 77790
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: OS X, i386
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: GC
+AssignedTo: lupus at ximian.com                            
+ReportedBy: bryan at imeem.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: OS X/i386: Problem with GC on non-main thread
+
+Description of Problem:
+
+Attached below will be a test case which crashes mono reproducibly on OS X/i386 but not on 
+ppc, as of SVN HEAD from this morning (r57941). The behavior is also exhibited with the test OS 
+X/i386 builds which have been posted.  I have a function which exercises the GC by allocating, 
+using, and freeing memory in a random fashion.  If it's run on the main thread, it works fine; if I 
+fire off a thread to run (and just sleep on the main thread), I get random stack corruption and 
+SIGSEGVs.
+
+Steps to reproduce the problem:
+
+1. in tc.cs, set USE_THREAD to true
+2. mcs tc.cs
+3. mono tc.exe
+
+Actual Results:
+When USE_THREAD is true, program runs for ~10 seconds, then throws an exception:
+
+Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of 
+an object
+in <0x0000f> System.Int32:Equals (System.Object o)
+in <0x00033> System.Object:Equals (System.Object a, System.Object b)
+in <0x000b8> System.Array:IndexOf (System.Array array, System.Object value, Int32 startIndex, 
+Int32 count)
+in <0x00043> System.Collections.ArrayList:IndexOf (System.Object value, Int32 startIndex, Int32 
+count)
+in <0x00021> System.Collections.ArrayList:IndexOf (System.Object value, Int32 startIndex)
+in <0x00019> System.Collections.ArrayList:IndexOf (System.Object value)
+in <0x00018> System.Collections.ArrayList:Remove (System.Object value)
+in <0x000ad> T:ExerciseGC ()
+in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
+
+If USE_THREAD is false, the program runs indefinitely with no crash.
+
+Expected Results:
+When USE_THREAD is true, the program should exit after 600 seconds without crashing.  When 
+USE_THREAD is false, the program should run indefinitely.
+
+How often does this happen? 
+Every run
+
+Additional Information:
+export GC_DONT_GC=1 keeps the GC from running, and the test case runs fine for both values 
+of USE_THREAD.
+
+If I compile libgc with DEBUG_THREADS information enabled, this is what I see:
+
+**** USE_THREADS = true ****
+
+Stopping the world from 0xd03
+Attempting to suspend thread 0xd03
+Attempting to suspend thread 0xd03
+World stopped from 0xd03
+Darwin: Stack for thread 0xa000cf80 = [bffff73c,c0000000)
+World starting
+World started
+Stopping the world from 0x2c03
+Attempting to suspend thread 0xd03
+Thread state for 0xd03 = 3
+Suspending 0xd03
+Attempting to suspend thread 0xf03
+Thread state for 0xf03 = 3
+Suspending 0xf03
+Attempting to suspend thread 0x1903
+Thread state for 0x1903 = 3
+Suspending 0x1903
+Attempting to suspend thread 0x2c03
+Attempting to suspend thread 0xd03
+Thread state for 0xd03 = 3
+Attempting to suspend thread 0xf03
+Thread state for 0xf03 = 3
+Attempting to suspend thread 0x1903
+Thread state for 0x1903 = 3
+Attempting to suspend thread 0x2c03
+World stopped from 0x2c03
+Darwin: Stack for thread 0xa000cf80 = [bffff68c,c0000000)
+World starting
+Thread state for 0xd03 = 3
+Resuming 0xd03
+Thread state for 0xf03 = 3
+Resuming 0xf03
+Thread state for 0x1903 = 3
+Resuming 0x1903
+World started
+Stopping the world from 0x2c03
+Attempting to suspend thread 0xd03
+Thread state for 0xd03 = 3
+Suspending 0xd03
+Attempting to suspend thread 0xf03
+Thread state for 0xf03 = 3
+Suspending 0xf03
+Attempting to suspend thread 0x1903
+Thread state for 0x1903 = 3
+Suspending 0x1903
+Attempting to suspend thread 0x2c03
+Attempting to suspend thread 0xd03
+Thread state for 0xd03 = 3
+Attempting to suspend thread 0xf03
+Thread state for 0xf03 = 3
+Attempting to suspend thread 0x1903
+Thread state for 0x1903 = 3
+Attempting to suspend thread 0x2c03
+World stopped from 0x2c03
+Darwin: Stack for thread 0xa000cf80 = [bffff68c,c0000000)
+World starting
+Thread state for 0xd03 = 3
+Resuming 0xd03
+Thread state for 0xf03 = 3
+Resuming 0xf03
+Thread state for 0x1903 = 3
+Resuming 0x1903
+World started
+
+Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of 
+an object
+in <0x0000f> System.Int32:Equals (System.Object o)
+in <0x00033> System.Object:Equals (System.Object a, System.Object b)
+in <0x000b8> System.Array:IndexOf (System.Array array, System.Object value, Int32 startIndex, 
+Int32 count)
+in <0x00043> System.Collections.ArrayList:IndexOf (System.Object value, Int32 startIndex, Int32 
+count)
+in <0x00021> System.Collections.ArrayList:IndexOf (System.Object value, Int32 startIndex)
+in <0x00019> System.Collections.ArrayList:IndexOf (System.Object value)
+in <0x00018> System.Collections.ArrayList:Remove (System.Object value)
+in <0x000ad> T:ExerciseGC ()
+in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
+
+... at which point the ExerciseGC thread has died and the 600 seconds expires.
+
+What is weird to me is that the second thread does not have a "Darwin: Stack for thread"... line, 
+only the main thread does.  I believe the allocation that triggers the GC happens on the 
+ExerciseGC thread, as the main one is just sleeping, but only the main thread (as shown by the 
+bottom of the stack being the hardcoded GC_stackbottom value) is shown.
+
+**** USE_THREADS = false ****
+
+Stopping the world from 0xd03
+Attempting to suspend thread 0xd03
+Attempting to suspend thread 0xd03
+World stopped from 0xd03
+Darwin: Stack for thread 0xa000cf80 = [bffff73c,c0000000)
+World starting
+World started
+Stopping the world from 0xd03
+Attempting to suspend thread 0xd03
+Attempting to suspend thread 0xf03
+Thread state for 0xf03 = 3
+Suspending 0xf03
+Attempting to suspend thread 0x1903
+Thread state for 0x1903 = 3
+Suspending 0x1903
+Attempting to suspend thread 0xd03
+Attempting to suspend thread 0xf03
+Thread state for 0xf03 = 3
+Attempting to suspend thread 0x1903
+Thread state for 0x1903 = 3
+World stopped from 0xd03
+Darwin: Stack for thread 0xa000cf80 = [bffff42c,c0000000)
+World starting
+Thread state for 0xf03 = 3
+Resuming 0xf03
+Thread state for 0x1903 = 3
+Resuming 0x1903
+World started
+(...repeats as collections happen...)


More information about the mono-bugs mailing list