Bug 59281 - System.Threading.AbandonedMutexException: The wait completed due to an abandoned mutex.
Summary: System.Threading.AbandonedMutexException: The wait completed due to an abando...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer (show other bugs)
Version: unspecified
Hardware: PC All
: --- normal
Target Milestone: 15.5
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2017-09-07 08:29 UTC by Jean-Baptiste
Modified: 2017-10-20 17:46 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: Yes
Last known good build: mono 4.8


Attachments
test program (1.88 KB, text/plain)
2017-09-07 08:29 UTC, Jean-Baptiste
Details

Description Jean-Baptiste 2017-09-07 08:29:20 UTC
Created attachment 24615 [details]
test program

Issue with mutex/thread in mono 5.2. The crash is random (program is attached to the case)
This test program is OK with mono 4.8

Env : CentoS 7 + rpm from download.mono-project.com/repo/centos7

[root@centos72 ~]# mono --debug Program.exe
Thread 1 iter:0 with mutex:0
Thread 1 ended
Thread 2 iter:0 with mutex:0

Unhandled Exception:
System.Threading.AbandonedMutexException: The wait completed due to an abandoned mutex.
  at System.Threading.WaitHandle.ThrowAbandonedMutexException (System.Int32 location, System.Threading.WaitHandle handle) [0x00000] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/waithandle.cs:635
  at System.Threading.WaitHandle.WaitAny (System.Threading.WaitHandle[] waitHandles, System.Int32 millisecondsTimeout, System.Boolean exitContext) [0x000d4] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/waithandle.cs:493
  at System.Threading.WaitHandle.WaitAny (System.Threading.WaitHandle[] waitHandles) [0x00000] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/waithandle.cs:531
  at testlock.Program.Thread2 () [0x00006] in <5effadd55ff046a3b2f3c465f0cf3c78>:0
  at testlock.Program+<>c.<Main>b__3_1 () [0x00000] in <5effadd55ff046a3b2f3c465f0cf3c78>:0
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:893
  at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105
[ERROR] FATAL UNHANDLED EXCEPTION: System.Threading.AbandonedMutexException: The wait completed due to an abandoned mutex.
  at System.Threading.WaitHandle.ThrowAbandonedMutexException (System.Int32 location, System.Threading.WaitHandle handle) [0x00000] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/waithandle.cs:635
  at System.Threading.WaitHandle.WaitAny (System.Threading.WaitHandle[] waitHandles, System.Int32 millisecondsTimeout, System.Boolean exitContext) [0x000d4] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/waithandle.cs:493
  at System.Threading.WaitHandle.WaitAny (System.Threading.WaitHandle[] waitHandles) [0x00000] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/waithandle.cs:531
  at testlock.Program.Thread2 () [0x00006] in <5effadd55ff046a3b2f3c465f0cf3c78>:0
  at testlock.Program+<>c.<Main>b__3_1 () [0x00000] in <5effadd55ff046a3b2f3c465f0cf3c78>:0
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:893
  at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /builddir/build/BUILD/mono-5.2.0.215/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105
Comment 1 Ludovic Henry 2017-09-21 19:56:19 UTC
Fixed with https://github.com/mono/mono/pull/5625
Comment 2 Ludovic Henry 2017-10-03 18:30:53 UTC
Backported to 2017-06 (https://github.com/mono/mono/pull/5650) and 2017-08 (https://github.com/mono/mono/pull/5649)

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

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