Bug 23146 - AbandonedMutexException is not thrown - so the WaitHandle.Wait* methods is broken
Summary: AbandonedMutexException is not thrown - so the WaitHandle.Wait* methods is br...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer (show other bugs)
Version: 3.8.0
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-18 08:43 UTC by Mike
Modified: 2018-02-28 22:02 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
unit test patch (1.15 KB, patch)
2015-11-17 16:18 UTC, Vincent Povirk
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mike 2014-09-18 08:43:43 UTC
MSDN sample that executes a thread that abandons five mutexes is not working on mono - it simply hangs in infinite wait.
The reproduction is an example from
http://msdn.microsoft.com/en-us/library/system.threading.abandonedmutexexception(v=vs.110).aspx

The issue is 100% reproducible on latest mono master (3.10.x) running
on ubuntu server 14.04 and also on
=== Xamarin Studio ===
Version 5.4 (build 239)
Installation UUID: 4693647f-46e0-4046-b430-f4f086d7fd6f
Runtime:
    Mono 3.8.0 ((no/45d0ba1)
    GTK+ 2.24.23 (Raleigh theme)
    Package version: 308000009
=== Build Information ===
Release ID: 504000239
Git revision: 338110385bb89c5774e89ffcb15d8f2039e7fbcd
Build date: 2014-09-16 12:25:53-04
Xamarin addins: 05241f5ab70cf79388a0f113bc6877780ed1024a
=== Operating System ===
Mac OS X 10.10.0
Darwin 14.0.0 Darwin Kernel Version 14.0.0
Comment 1 Vincent Povirk 2015-11-17 16:18:52 UTC
Created attachment 13846 [details]
unit test patch

Mono has a test for this situation which fails on Windows, in MonoTests.System.Threading.MutexTest. Here's a diff that changes it to expect the Windows behavior (and thus passes on Windows and fails in Mono).
Comment 2 Ludovic Henry 2018-02-28 22:02:51 UTC
I cannot reproduce with Mono 5.13.0.220 (master/798c5efa52a), the sample from https://msdn.microsoft.com/en-us/library/system.threading.abandonedmutexexception(v=vs.110).aspx finishes with expected output of

> Thread exits without releasing the mutexes.
> Exception on return from WaitOne.
> 	Message: The wait completed due to an abandoned mutex.
> Exception on return from WaitAny at index 1.
> 	Message: The wait completed due to an abandoned mutex.
> Exception on return from WaitAll. MutexIndex = -1.
> 	Message: The wait completed due to an abandoned mutex.