Knowledge Base
Searching in : Article
ID: AR01O00916
Applies to: NoMachine Software
Added on: 2017-01-18
Last Update: 2019-02-01

Cannot create a NoMachine XDM virtual desktop (how to solve MIT-SHM issues)

A new NoMachine virtual desktop started via XDMCP (i.e. a NoMachine XDM virtual desktop session type) failing to start with error:

"The session negotiation failed. Error: Failed to connect to nxclient --monitor"

may indicate a possible issue with the MIT Shared Memory Extension (MIT-SHM ) of X. 

To verify this, check the 'session' log file in the user's home/.nx/M-...  (or F-M-...) directory on the server host and look for an error similar to:

X Error of failed request:  BadAccess (attempt to access private resource denied)
  Major opcode of failed request:  130 (MIT-SHM)
  Minor opcode of failed request:  1 (X_ShmAttach)

This indicates that the NoMachine display server (which acts as an X server, but doesn't run as 'root' by design), was unable to access the shared memory and failed to start. Consequently none of the NoMachine processes necessary for creating the virtual desktop (like 'nxclient --monitor' mentioned in the error above) are started and the session fails.

This problem occurs with KDM (but may affect also other Qt-based display managers) which allocate MIT-SHM segments with display manager's permissions. Since the NoMachine virtual X server doesn't have 'root' permissions, it's forbidden to access such shared memory segments.

The system X server, instead, runs with 'root' permissions and can access the MIT-SHM, that's why the desktop starts on locale.

 

Possible workarounds:

i) Use a different display manager, like GDM or LightDM

or

ii) Force the display manager to not use MIT-SHM:

Stop the display manager by system tools. 

Rename the original display manager startup script .

Create the wrapper script to set 'QT_X11_NO_MITSHM=1' in the environment and replace the original startup file (in our example, kdm_greet).

Set executable permissions to the wrapper script.

Restart the display manager.

 

A practical example:

1. Stop KDM
        systemctl stop kdm

2. Move to kdm_greet location
        cd /usr/lib/kde4/libexec/

3. There create a wrapper script kdm_greet.sh with this content:
        #!/bin/bash
        exec env QT_X11_NO_MITSHM=1 $0.bin "$@"

4. Backup original kdm_greet and swap files:
        cp -a kdm_greet kdm_greet.original
        mv kdm_greet kdm_greet.bin
        mv kdm_greet.sh kdm_greet

5. Adjust permissions:
        chmod +x kdm_greet

6. Start KDM:
        systemctl start kdm

 

Note for multi-node environments

Any of the previous workarounds has to be applied on each of the remote nodes affected by the problem.