Root-less Xorg does not detect displays, which leads to segfault in mutter

I’m currently trying to investigate an issue:

Driver: 378.13, KMS enabled.

gdm starts in wayland mode and gnome-shell wayland session works more or less fine.

Trying to start gnome-shell Xorg session causes a crash in libmutter.

The crash occurs here:

MetaLogicalMonitor *primary;

  primary =
    meta_monitor_manager_get_primary_logical_monitor (monitor_manager);

  meta_backend_warp_pointer (backend,
                             primary->rect.x + primary->rect.width / 2,
                             primary->rect.y + primary->rect.height / 2);

because ‘primary’ pointers’ value is nullptr, and accessing it’s members of course causes a segfault, which means, there are no (primary) displays.

Starting “lightdm --test-mode” as a root provides a workaround and causes Xorg and/or nvidia driver to find displays.

/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): Valid display device(s) on GPU-0 at PCI:3:0:0
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-0 (boot)
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-1
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-2
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-3
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-4
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-5
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-6
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(0): DFP-7

/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(GPU-0): DELL U2412M (DFP-0): connected
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(GPU-0): DELL U2412M (DFP-0): Internal TMDS
/usr/lib/gdm3/gdm-x-session: (--) NVIDIA(GPU-0): DELL U2412M (DFP-0): 330.0 MHz maximum pixel clock

After doing this gnome-shell Xorg session works fine.
I presume, starting lightdm as root somehow causes nvidia driver to initialize displays.

Could you give me an advise, what could be the reason for the problem? Why doesn’t Xorg find monitors on nvidia drivers, when it’s started without root privileges?

Have you reported this in Gnome’s bug tracker?
Gnome developers are very helpful with crashes.

Crash in mutter is only a symptom, not the problem. For example i3wm session also won’t start.