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: Future Cycle (TBD)
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2017-09-07 08:29 UTC by Jean-Baptiste
Modified: 2017-10-03 18:30 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)

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