Bug 39836 - Running mono with MONO_ENABLE_SHM does not enable shared memory
Summary: Running mono with MONO_ENABLE_SHM does not enable shared memory
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 4.2.0 (C6)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-03-22 12:57 UTC by Roman M. Yagodin
Modified: 2016-04-04 19:58 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

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:

Description Roman M. Yagodin 2016-03-22 12:57:08 UTC
In recent mono releases, running mono with MONO_ENABLE_SHM=1 environment variable does not seems to enable shared memory anymore.

Issue noticed in mono 4.2.2 and 4.2.3. 

The following program runs fine on Microsoft .NET in Windows (first process waits on semaphore and prints "Signaled!" when waits again, the second just signals semaphore and exit), but on Mono in Linux even with MONO_ENABLE_SHM both processes wait indefinitely.

Program code to test issue:

using System;
using System.Threading;

namespace ShmBug
    class MainClass
        const string name = "MySystemSemaphoreObject_123hx5bwX7";

        public static void Main (string [] args)
            Semaphore semaphore;

            if (!Semaphore.TryOpenExisting (name, out semaphore))
                semaphore = new Semaphore (0, 1, name);

                Console.WriteLine ("Waiting...");

                while (semaphore.WaitOne ())
                    Console.WriteLine ("Signaled!");
                Console.WriteLine ("Semaphore exists, signal it.");
                semaphore.Release ();


$ MONO_ENABLE_SHM=1 mono ShmBug.exe

Operating system:

Linux mylaptop 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64 GNU/Linux

Mono version (installed from Xamarin Debian repository):

Mono JIT compiler version 4.2.3 (Stable Wed Mar 16 13:19:08 UTC 2016)
Comment 1 Zoltan Varga 2016-03-23 18:12:22 UTC
This functionality was removed as the implementation was very complicated and error prone on unix.
Comment 2 Roman M. Yagodin 2016-03-24 06:00:33 UTC
Sad news. I think this should be announced in mono release notes (couldn't find anything about that).
Comment 3 Zoltan Varga 2016-03-24 14:25:40 UTC
It is now documented in the 4.4 release notes: