Skip to content
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

Named mutex not working on Linux and MacOS when AOT compiling #110348

Open
darind opened this issue Dec 3, 2024 · 2 comments
Open

Named mutex not working on Linux and MacOS when AOT compiling #110348

darind opened this issue Dec 3, 2024 · 2 comments
Labels
area-System.Threading untriaged New issue has not been triaged by the area owner

Comments

@darind
Copy link

darind commented Dec 3, 2024

Description

Acquiring a global named mutex doesn't seem to work on MacOS and Linux when the application is compiled with NativeAOT.

Reproduction Steps

internal static class Program
{
    private static void Main(string[] args)
    {
        using (var mutex = new Mutex(false, "Global\\{604074dc-be47-4a35-b79d-b79eead0c022}"))
        {
            mutex.WaitOne();

            Console.WriteLine("The app is now running...");
            Console.ReadLine();
        }
    }
}

Compile to native using the following:

dotnet publish --configuration Release --runtime osx-x64 --output dist

Expected behavior

The second instance of the program blocks and waits until the first has terminated

Actual behavior

The second instance successfully acquires the mutex.

Regression?

No response

Known Workarounds

No response

Configuration

  • .net 8
  • MacOS and Linux (ubuntu 24)
  • x64

Other information

The same works if the application is not compiled to native code but simply build in release mode:

dotnet build --configuration Release
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 3, 2024
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
Member

I think this is #48720. Native AOT uses the managed Mutex implementation, not the one in CoreCLR PAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Threading untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants