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
Summary: WaitHandle.WaitAny deadlocks if the thread is interrupted
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
URL:
: 7003 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-11-23 07:15 UTC by Rolf Bjarne Kvinge
Modified: 2013-05-20 12:56 UTC (History)
4 users (show)

See Also:
Tags:


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

Description Rolf Bjarne Kvinge 2012-11-23 07:15:47 UTC
WaitHandle.WaitAny will deadlock if the thread is interrupted.
Comment 1 Rolf Bjarne Kvinge 2012-11-23 07:17:02 UTC
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 UTC
Created attachment 3002 [details]
Proposed fix
Comment 3 Rolf Bjarne Kvinge 2012-11-23 07:19:34 UTC
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 UTC
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 UTC
The patch looks good except the remaining time calculation doesn't handle ticks overflow.
Comment 6 Rodrigo Kumpera 2012-11-23 11:16:56 UTC
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 UTC
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 UTC
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 UTC
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 UTC
A slightly different version has been committed.

master: 87810b523ab2ce049decbed2184cd005c4f2c20a
2.10: 2209daad1c2fcfdfdd7117c710e01c58e0027d32
Comment 11 Mikayla Hutchinson 2013-05-20 12:56:42 UTC
*** 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.