This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 8566 - WaitHandle.WaitAny deadlocks if the thread is interrupted
: WaitHandle.WaitAny deadlocks if the thread is interrupted
Status: RESOLVED FIXED
Product: Runtime
Classification: Mono
Component: misc
: unspecified
: PC Mac OS
: --- normal
: ---
Assigned To: Rodrigo Kumpera
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-11-23 07:15 EST by Rolf Bjarne Kvinge
Modified: 2013-05-20 12:56 EDT (History)
4 users (show)

See Also:
Tags:
Test Case URL:
External Submit: ---


Attachments
Proposed fix (7.10 KB, patch)
2012-11-23 07:17 EST, Rolf Bjarne Kvinge
Details | Diff

Description Rolf Bjarne Kvinge 2012-11-23 07:15:47 EST
WaitHandle.WaitAny will deadlock if the thread is interrupted.
Comment 1 Rolf Bjarne Kvinge 2012-11-23 07:17:02 EST
This happens to mdtool:  it calls WaitAny and at process shutdown waits for the
thread to finish. The thread has been interrupted, so the WaitAny will never
return, thus the process will never exit either.
Comment 2 Rolf Bjarne Kvinge 2012-11-23 07:17:42 EST
Created attachment 3002 [details]
Proposed fix
Comment 3 Rolf Bjarne Kvinge 2012-11-23 07:19:34 EST
Rodrigo, I believe this is somewhat your area, can you review the attached
patch?
Comment 4 Rolf Bjarne Kvinge 2012-11-23 07:20:32 EST
It looks like this was detected some time ago:
https://bugzilla.novell.com/show_bug.cgi?id=549807#c5
Comment 5 Rodrigo Kumpera 2012-11-23 11:12:19 EST
The patch looks good except the remaining time calculation doesn't handle ticks
overflow.
Comment 6 Rodrigo Kumpera 2012-11-23 11:16:56 EST
Nerver mind, we're using unsigned math already which handles this fine. So,
patch looks good, please commit.
Comment 7 Rolf Bjarne Kvinge 2012-11-23 11:22:41 EST
Would it be better to use mono_100ns_ticks instead of mono_msec_ticks? If I did
the math right it won't overflow in 29k years.
Comment 8 Rodrigo Kumpera 2012-11-23 11:48:09 EST
It doesn't matter, both are monotonic, which is important. The current schema
would only be a problem if we get 2 wrap around in the same call, which is not
an issue at all.
Comment 9 Rolf Bjarne Kvinge 2012-11-23 17:16:17 EST
From the implementation of mono_msec_ticks it looks like it will overflow every
49 days (the number of ms that fit in a uint32).
Comment 10 Rolf Bjarne Kvinge 2012-11-27 19:23:54 EST
A slightly different version has been committed.

master: 87810b523ab2ce049decbed2184cd005c4f2c20a
2.10: 2209daad1c2fcfdfdd7117c710e01c58e0027d32
Comment 11 Michael Hutchinson 2013-05-20 12:56:42 EDT
*** Bug 7003 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.