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)

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


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 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)