dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.36k stars 4.75k forks source link

[Mono] Named mutexes are not working cross-process #36307

Open kouvel opened 4 years ago

kouvel commented 4 years ago

The following test is failing, it looks like named mutexes used cross-process are not working: https://github.com/dotnet/runtime/blob/14835fbb7fdb2065983866ac186ed8408ee9b388/src/libraries/System.Threading/tests/MutexTests.cs#L407

Output:

System.AggregateException : One or more errors occurred. (Remote process failed with an unhandled exception.)\n---- Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Remote process failed with an unhandled exception.

   at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__1() in /_/src/libraries/Common/tests/System/Threading/ThreadTestHelpers.cs:line 52
   at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__2() in /_/src/libraries/Common/tests/System/Threading/ThreadTestHelpers.cs:line 57
   at System.Threading.Tests.ThreadTestHelpers.RunTestInBackgroundThread(Action test) in /_/src/libraries/Common/tests/System/Threading/ThreadTestHelpers.cs:line 108
   at System.Threading.Tests.MutexTests.CrossProcess_NamedMutex_ProtectedFileAccessAtomic(String prefix) in /_/src/libraries/System.Threading/tests/MutexTests.cs:line 411
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 359
----- Inner Stack Trace -----

Child exception:
  System.Threading.WaitHandleCannotBeOpenedException: No handle of the given name exists.
   at System.Threading.Mutex.OpenExisting(String name) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.cs:line 47
   at System.Threading.Tests.MutexTests.<>c.<CrossProcess_NamedMutex_ProtectedFileAccessAtomic>b__15_1(String m, String f) in /_/src/libraries/System.Threading/tests/MutexTests.cs:line 417
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 359

Child process:
  System.Threading.Tests, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 System.Threading.Tests.MutexTests+<>c Void <CrossProcess_NamedMutex_ProtectedFileAccessAtomic>b__15_1(System.String, System.String)

Child arguments:
  4f0f3cb57d5d4a829ed482bd5e0633897e26520d8a4f4b3fbfe733be1414a3df, /tmp/MutexTests_wr0kxyxs.z1h/CrossProcess_NamedMutex_ProtectedFileAccessAtomic_408_6634c51e

Failed in CI run: https://dev.azure.com/dnceng/public/_build/results?buildId=640943&view=ms.vss-test-web.build-test-results-tab

Might be a known issue. The test was disabled before the runtime repo existed. I was trying to enable it in https://github.com/dotnet/runtime/pull/36268 and saw the failures. For now I'll be disabling that test on Mono in that PR.

stephentoub commented 4 years ago

Last I knew, mono implemented named sync primitives to be process-wide rather than system-wide names.

lambdageek commented 4 years ago

Stephen is correct.