NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.32k stars 14.29k forks source link

Xorg crashes at startup, starting graphical session impossible #352328

Open cxandru opened 3 weeks ago

cxandru commented 3 weeks ago

Describe the bug

Nixos fails to start Xorg (at commit 27e30d177e57d912d614c88c622dcfdb2e6e6515, so unstable on October 1. Why am I not using the most recent one, you may ask? Well, because there I encounter https://github.com/NixOS/nixpkgs/issues/349816)).

It either stays stuck at the systemd message "Starting Displaymanager", or on "Process Core Dump (In both cases there is a core dump). coredumpctl reveals: 1447 0 0 SIGABRT inaccessible /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/Xorg The contents of /var/log/X.0.log are:

[    16.287] (II) Initializing extension GLX
[    16.339] (EE)
[    16.339] (EE) Backtrace:
[    16.340] (EE) 0: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/X (OsSigHandler+0x33) [0x5c29a3]
[    16.341] (EE) unw_get_proc_name failed: no unwind info found [-10]
[    16.341] (EE) 1: /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/libc.so.6 (?+0x0) [0x7fe0fde4b5c0]
[    16.342] (EE) 2: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/lib/xorg/modules/extensions/libglx.so (glxConvertConfigs+0x12) [0x7fe0fdc15b92]
[    16.343] (EE) 3: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/lib/xorg/modules/extensions/libglx.so (__glXDRIscreenProbe+0x2e8) [0x7fe0fdc1de98]
[    16.344] (EE) 4: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/lib/xorg/modules/extensions/libglx.so (xorgGlxServerInit+0xb7) [0x7fe0fdc142b7]
[    16.344] (EE) 5: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/X (_CallCallbacks+0x34) [0x44c474]
[    16.345] (EE) 6: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/X (GlxExtensionInit+0x15f) [0x57e72f]
[    16.346] (EE) 7: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/X (InitExtensions+0x89) [0x4bba69]
[    16.346] (EE) 8: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/X (dix_main+0x1ac) [0x44ad8c]
[    16.347] (EE) 9: /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/libc.so.6 (__libc_start_call_main+0x7e) [0x7fe0fde3514e]
[    16.348] (EE) 10: /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/libc.so.6 (__libc_start_main+0x89) [0x7fe0fde35209]
[    16.349] (EE) 11: /nix/store/x9zy8n82bdi9aapgy6p3hiqvyv5iw6fa-xorg-server-21.1.13/bin/X (_start+

Expected behavior

Xorg doesn't segfault on startup

Additional context

This is my current xserver-related setup, though I've also tried it with commenting it all out and it doesn't make a difference:

  services.xserver.videoDrivers = [ "intel" ];
  services.xserver.deviceSection = ''
    Option "TearFree" "true"
  '';
  services.xserver = {
    enable = true;
    xkb.layout = "de";
    xkb.variant = "neo";
    videoDrivers = [ "intel" ];
    #xfce
    desktopManager = {
      xterm.enable = false;
      xfce = {
        enable = true;
      };
    };
  };
hardware.graphics.extraPackages = [ pkgs.mesa.drivers ];

I have Intel integrated graphics: (hwinfo output is: Intel 3rd Gen Core processor Graphics Controller)

Metadata

(this is incomplete as I writing this issue from the rolled-back version of the OS, but I already mentioned the exact commit above)

Atemu commented 3 weeks ago

Please nixos-rebuild boot and then reboot.

Are you mixing nixpkgs revisions?

cxandru commented 2 weeks ago

Please nixos-rebuild boot and then reboot.

I did that

Are you mixing nixpkgs revisions?

I'm pinning nixpgks the oldschool way:

pkgs.mkShell {
  nixkpkgsUrl = "https://github.com/NixOS/nixpkgs/archive/27e30d177e57d912d614c88c622dcfdb2e6e6515.tar.gz";
  shellHook = ''
    rebuild () {
      echo Copying config from ~/.cfg
      sudo cp -rf ${config} ${extensions} /etc/nixos
      sudo nixos-rebuild -I "nixpkgs=${nixkpkgsUrl}" $@
    }
  '';
}
cxandru commented 2 weeks ago

So, the problem does go away when I comment out hardware.graphics.extraPackages = [ pkgs.mesa.drivers ];, apparently I actually hadn't tried that. But, this means no Mesa support, which means e.g. I can't run blender (See Blender segfaults on start · Issue #75868 · NixOS/nixpkgs (adding mesa, as suggested in this comment there had previously fixed that issue for me)

Examing the coredump log led me to this Archlinux Subreddit thread: Xorg segfault with xinit : r/archlinux. I have Intel HD Graphics 4000, which according to this answer should be supported by the crocus driver.

My question is: It seems that somehow the option Option "DRI" "crocus" would need to be configured, but /etc/X11/xorg.conf.d/20-intel.conf seems to be ignored under nixos, is there some package option where it can be added?

I tried adding it in services.xserver.deviceSection in my configuration.nix, but it didn't do anything there either.

Atemu commented 2 weeks ago

when I comment out hardware.graphics.extraPackages = [ pkgs.mesa.drivers ];,

That is redundant because mesa is in the global graphics driver packages path by default. Doing this shouldn't break anything which is why I suspected you might be mixing nixpkgs revisions because adding a different version of Mesa here would indeed break things.

What actually must have helped for that person in the other thread was not running blender from a nix-shell that likely used a different revision to their mesa. I'll state again that mixing Nixpkgs revisions is not supported and will likely not work, especially not for graphics-related things. It's like doing a partial upgrade in Arch terms.

somehow the option Option "DRI" "crocus" would need to be configured

It shouldn't. The default modesetting should work just fine but I don't know about these legacy drivers. Anyhow, the proper way to do this would be to set services.xserver.videoDrivers = [ "drivername" ];. There doesn't appear to be an xf86video driver for crocus though, so I'm not entirely sure which one you should set. I'd start with intel but perhaps it's actually intended to be used with modesetting?

cc @K900

Shados commented 2 weeks ago

@cxandru I had the same issue; I fixed it by swapping from services.xserver.videoDrivers = [ "intel" ]; to the "modesetting" driver. Adding Option "DRI" "crocus" to services.xserver.deviceSection then also seems to have worked fine, judging by the xorg log:

[  1584.081] (II) modeset(0): [DRI2] Setup complete
[  1584.081] (II) modeset(0): [DRI2]   DRI driver: crocus

...

[  1584.103] (II) AIGLX: Loaded and initialized crocus

(although I guess it might have been using crocus to begin with)