[Mono-bugs] [Bug 561239] New: Monitor.Pulse() Monitor.Wait() Thread.Abort() cause mono hang

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Dec 6 20:50:43 EST 2009



           Summary: Monitor.Pulse() Monitor.Wait() Thread.Abort() cause
                    mono hang
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: i686
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: wmrieker at nii.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

Created an attachment (id=331278)
 --> (http://bugzilla.novell.com/attachment.cgi?id=331278)
fixed monitor.c (original from svn 138189) and test program

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64;
GTB6.3; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)

1)Have a main program create a thread with new Thread() and start it with
2)Have the main program lock an object with Monitor.Enter() then wait for the
thread to set a flag by waiting with Monitor.Wait()
3)Have the thread lock the object with Monitor.Enter(), set the flag, do a
Monitor.Pulse() to wake the main program, then wait forever with Monitor.Wait()
4)When the main program wakes, have it abort the thread with thread.Abort()
while thread is still waiting in Monitor.Wait()
5)Have main program wait for thread to complete with thread.Join()
6)repeat back to step 1

After a few (< 100 or so) iterations, it hangs because the Monitor.Pulse()
never wakes the main thread.

The reason is that the event placed in the mon->wait_list struct by the
thread's Monitor.Wait() is never freed off as the thread is aborted with
thread.Abort().  So when that mon struct gets reused by a later thread, it has
that old event in there, and the Monitor.Pulse() wakes that old event, not
waking the event placed in there by the main thread.

Reproducible: Always

Steps to Reproduce:
see description above, or use test program in attachment
Actual Results:  
attached program hangs after < 100 iterations (at least on my system)

Expected Results:  
it should keep running and running as it does when my change (in the
attachment) is applied

(the descriptions of the categories are terrible, yes I know that runtime is
runtime, but I'm not really sure what you consider runtime vs classes).

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list