-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support inter-process named mutexes in managed Mutex implementation #48720
Comments
Edit Ah, my mistake. This is strictly more than what Mono could do before. Thanks for clarifying Stephen. This is just for in-process named mutexes. Not inter-process named mutexes on non-Windows. |
Note that coreclr supports interprocess named mutexes on Unix. If the goal here is to be able to switch coreclr to use the managed implementation as well, that support needs to be brought to the managed implementation as well, at which point hopefully it would also work on mono. |
This is now also causing problems for our experimental s390x port (features/s390x in runtimelab), because we use the Mono runtime for everything on our platform. After this change, we now see failures due to use of named Mutexes in parts of the .NET SDK itself. For example, "dotnet new console" now fails with:
Similarly, the roslyn compile server code uses named mutexes for serialization (see e.g. src/Compilers/Shared/BuildServerConnection.cs) that now cause failures. Now I understand that the old implementation in Mono was not really complete, but at least it allowed these tasks to operate ... What is the recommended way forward here? Is there a plan to add full support for named Mutexes to the managed implementation? Or should we try to work around this by eliminiating use of named Mutexes in the templating code and roslyn? |
The Roslyn code looks like it was adjusted to work properly with in-process named mutexes only, so adding support for that to the managed implementation would unblock you (and allow us to re-enable a lot of the test suite). I'd like to see that happen before 6.0, but I don't have immediate plans to implement it. I don't think adding support for in-process named mutexes would be too complicated, if that's of any interest on your end? We would certainly take the change in Mono. I'll be busy with wasm work for the next couple sprints, so I would not expect any more threading implementation work on my end for another month or two. |
It took me a while to get to that, sorry. I've now posted a PR implementing this suggestion. Let me know if there's anything I should be doing different. Thanks! |
* Partially addresses #48720 * Use a dictionary to perform the name to object lookup * Allow multiple handles to refer to a single waitable object * Abandon mutex only when all handles refering to it are closed * Re-enable test cases disabled due to the above issue
Since in-process named mutex support was implemented - and is sufficient for mobile scenarios - this issue has been updated to track support for inter-process named mutex emulation. Bumping milestone to net7 |
Revisiting this a bit. we should be really clear on the use-case for named inter-process mutexes and on the complications from trying to reuse the CoreCLR implementation:
I'm not sure if (3) is really something we're striving for. If we only want (2) or a version of (3) where mono named mutexes only interoperate with other mono processes (and not with coreclr) we could probably implement something as long as we use a slightly different naming convention that doesn't collide with coreclr. |
The implementation of named mutexes on CoreCLR is tricky and security sensitive. I do not think we would want to maintain two parallel implementations. If we want to do something here, we should lift the CoreCLR PAL implementation to C# and share it with Mono. Yes, it is a bunch of work. |
Update in-process named mutexes are now implemented since #55199 For WebAssembly and ios/Android this is sufficient.
We may still want to implement inter-process named mutex emulation using a mechanism similar to https://github.com/dotnet/runtime/blob/main/src/coreclr/pal/src/include/pal/mutex.hpp
As discussed in #55199 (comment) the approach would be to cherrypick the support from the CoreCLR PAL into a src/libraries PAL implementation.
Original
Some tests rely on this behavior, and so now with Mono migrating implementations they are temporarily disabled.
The text was updated successfully, but these errors were encountered: