Skip to content

nixos-rebuild switch crashes/quits DE/WM #146727

Closed

Description

@rollschild

Describe the bug

While trying to upgrade the system using nixos-rebuild switch, it crashed/quit the window manager (I'm using Sway) and hang there with a black screen and a white cursor forever. I had to force the machine to shutdown.

After I reboot the machine, when I tried nixos-rebuild switch again, it would just say could not find any previously installed systemd-boot and exit the command, not doing any upgrade at all. I had to manually do sudo bootctl install, as suggested in this discourse topic and reboot the machine several times to finally get rid of this issue and be able to upgrade again.

When I thought the issue went away, a couple of days later, during the process of nixos-rebuild switch, the WM just crashed again and the same thing happened again. Does anyone know what happened or what i did wrong?

I also created a separate discourse topic for this. Based on the replies from other users, this issue happened on KDE Plasma as well.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nixos-rebuild switch
  2. wait til the command finishes

Expected behavior

The command successfully runs and exits, without quitting the desktop environment.

Screenshots

IMG_20211117_173312

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.79, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4`
 - channels(rollschild): `""`
 - channels(root): `"nixos-21.11pre332033.715f6341195, nixpkgs-21.11pre293858.141b2b111d7"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

UPDATE:

There's a similar issue but I don't think it's the same exact issue because in my case there weren't any errors. Sway just automatically quit and all I saw was a black screen with a white cursor.

Activity

  1. added
    0.kind: bug
    on Nov 20, 2021
  2. nixos-discourse commented on Nov 20, 2021

    @nixos-discourse
  3. kurnevsky commented on Nov 20, 2021

    @kurnevsky
    Member

    Something similar happened to me couple of times with xmonad, when a lot of packages were rebuilt. But it didn't hang the system, just exited my X11 and gave me the terminal (probably because I use xinit).

  4. primeos commented on Nov 20, 2021

    @primeos
    Member

    While trying to upgrade the system using nixos-rebuild switch, it crashed/quit the window manager (I'm using Sway) and hang there with a black screen and a white cursor forever. I had to force the machine to shutdown.

    I can confirm that part. Sway didn't technically crash (at least in my case) but I kinda got thrown back to the tty/VT and had to kill Sway via Ctrl+C. Really sucks... Likely another case of a komplex NixOS / activation script change that got merged without a proper review. It first happened to me during this week (I didn't update for a while) and I'll try to trace it down during the weekend (was already on my TODO list).

    Might be something like #141192 (could be completely unrelated but I immediately disliked what I saw there tbh).

  5. mohe2015 commented on Nov 20, 2021

    @mohe2015
    Contributor

    Really sucks... Likely another case of a komplex NixOS / activation script change that got merged without a proper review.
    Might be something like #141192 (could be completely unrelated but I immediately disliked what I saw there tbh).

    While I can understand your frustration I think you could've phrased that a bit nicer.

  6. primeos commented on Nov 20, 2021

    @primeos
    Member

    Well, tbh that was already the heavily filtered and nice version (apart from the immediately disliked what I saw there, that could come off the wrong way, I mainly meant that such a complex change got merged very quickly and with few reviews even though it was problematic before and might be controversial in the first place - and I'm complaining about the process, not individuals).

    I'm just very frustrated (to put it mildly) because this stuff happens again and again (at least just once or twice per year, but still..) and I often have to deal with it...

  7. added
    6.topic: nixos
    on Nov 21, 2021
  8. Artturin commented on Nov 22, 2021

    @Artturin
    Member

    Made this pr for an unrelated issue but could someone test if it helps #146964

    systemd.additionalUpstreamSystemUnits = [ "dbus-org.freedesktop.login1.service" ];

  9. dschrempf commented on Nov 24, 2021

    @dschrempf
    Contributor

    Just to mention: This also happens with X11 and XMonad when using the provided NixOS services.

  10. SFrijters commented on Nov 24, 2021

    @SFrijters
    Member

    Seeing the same thing with X11+Openbox. I've updated my system to include #146964 but I think it's only clear if this works if a subsequent update would trigger a restart of the problem units, right?

  11. rollschild commented on Nov 24, 2021

    @rollschild
    Author

    The tricky part of this issue is that I was able to upgrade without quitting Sway and I thought the issue was resolved (although at the end of the text outputs of nixos-rebuild switch it still said could not find any previously installed systemd-boot). But a couple of days later when I tried upgrading again this issue resurfaced. Let me try to upgrade a couple more times and if this issue doesn't show up again I can close this.

  12. Artturin commented on Nov 24, 2021

    @Artturin
    Member

    Please send logs from journalctl

    journalctl -b -1 can be used to see the previous boot

  13. starcraft66 commented on Nov 25, 2021

    @starcraft66
    Member

    Just wanted to chime in and say I've experienced this numerous times on X11 using i3. The only way to rebuild properly is doing it from a tty.

  14. Artturin commented on Nov 25, 2021

    @Artturin
    Member

    Logs?

  15. ncfavier commented on Nov 25, 2021

    @ncfavier
    Member

    could not find any previously installed systemd-boot

    I think this might be related to #140046

  16. flokli commented on Nov 25, 2021

    @flokli
    Member

    There's two issues intertwined here. One is restarting too many graphical-related services (probably introduced by #141192), the other one was a too strict regex when detecting bootloaders (which was fixed with #140046).

  17. added a commit that references this issue on Nov 27, 2021
    1cfecb6
  18. primeos commented on Nov 27, 2021

    @primeos
    Member

    One is restarting too many graphical-related services (probably introduced by #141192)

    I finally had time to look at this and it is indeed caused by #141192 as I feared. I recommend to revert it ASAP: #147609

  19. dasJ commented on Nov 27, 2021

    @dasJ
    Member

    As author of the breaking PR I'm really sorry that this happened and I understand the frustration. Of course I'm not against reverting this PR if it breaks people's systems but if it isn't reverted this weekend I'll take some time during this weekend and try to reproduce and fix the mentioned issues. Again, I'm not saying people should just live with their broken systems until I find some magic solution so if it's coming to a revert I'll live with rebuilding an improved PR.

    One thing that should be considered if this is reverted is whether to revert it on both master and 21.11 or just on 21.11 (people just seemed to have lived with the issues on unstable). Again, I'm not telling anyone what to do here, just adding this to consider.

  20. added a commit that references this issue on Nov 27, 2021
    7abd522
  21. primeos commented on Nov 27, 2021

    @primeos
    Member

    As author of the breaking PR I'm really sorry that this happened and I understand the frustration.

    Thanks! I'm really frustrated by this kind of issue (it's currently my main frustration with NixOS but luckily such regressions are very rare - although not rare enough) but of course my frustration is not with you. There where a lot of things that went wrong here (no VM test that could've catched it, not enough reviews, too quickly merged, to few bug reports/complaints, etc.) and I hope that we can improve the process over time (I'll try to help with that as good as I can - e.g. I hope that I'll have time soon to write a VM test that could catch this issue before it hits a channel: #146809 - also huge thanks to @Artturin for #147272 which seems like a good idea in general).

    Again, I'm not saying people should just live with their broken systems until I find some magic solution so if it's coming to a revert I'll live with rebuilding an improved PR.

    I'm definitely also for reverting it ASAP, especially with the NixOS 21.11 release imminent. Huge thanks to @nrdxp for sharing that opinion.

    people just seemed to have lived with the issues on unstable

    That's something I find really strange... No idea why there where so few reports :o (maybe it doesn't affect KDE/Gnome (as much), people didn't want to open a bug report without additional information, or most did indeed just live with it).

    rebuilding an improved PR

    One request: Please ping me for a review. Thanks :)
    (One unfortunate issue with the last PR was that it wasn't mentioned in #74899 so I only got the notification when the issue was closed by merging the PR (#74899 (comment)). I should've still added a comment and tested it but I was very low on time and hoped that it'd be fine this time.)

  22. mohe2015 commented on Nov 27, 2021

    @mohe2015
    Contributor

    people just seemed to have lived with the issues on unstable

    That's something I find really strange... No idea why there where so few reports :o (maybe it doesn't affect KDE/Gnome (as much), people didn't want to open a bug report without additional information, or most did indeed just live with it).

    I'm in that part of people.

  23. evils commented on Nov 28, 2021

    @evils
    Member

    FWIW
    i experienced this issue on 2021-11-03 (on sway) and didn't report it

    i assumed it was a one-off (something i think may not be worth avoiding on nixos-unstable)
    an incorrect conclusion that was re-enforced by me only getting a third occurrence on sway yesterday

    even though the issue did occur on every new switch on my laptop running i3 (which i only use occasionally (probably spanning changes that trigger this issue)),
    i assumed that was an adequately different system that the issue wasn't related
    and X based stuff is common enough that i thought someone would be on it

    i'm definitely going to be more likely to report this kind of stuff in the future
    especially when we're approaching a release branch-off

    though lack of know-how on collecting data about such a crash definitely held me back from filling in the bug report issue template as well
    ("it crashed" doesn't feel like an actionable report to me, especially in this case as running switch immediately after, doesn't cause the issue again)

    i felt obliged to investigate before reporting, but since i had no idea what could have caused it, didn't want to spend a lot of time on this, and assumed someone more familiar with the matter would catch it

  24. dasJ commented on Nov 28, 2021

    @dasJ
    Member

    One thing I am wondering is what the exact conditions are to trigger this issue. We've been running this change on close to 70 different system configurations deployed to a couple of hundred devices that are headless, using i3, or a full KDE environment and nothing ever happened. I'm not saying these problem's don't exist, I'm just curious why they show up. Does anyone have the switch-to-configuration output for an affected system? If not there's not really a lot I can do because I am unable to reproduce this.

    Edit the systemd-logind assumption from discourse seems to be wrong. When I change my logind unit, no logind and hence no i3 is restarted:

    stopping the following units: cups.service, systemd-networkd.service
    Warning: Stopping systemd-networkd.service, but it can still be activated by:
      systemd-networkd.socket
    activating the configuration...
    setting up /etc...
    reloading user units for janne...
    setting up tmpfiles
    reloading the following units: dbus.service, nftables.service
    restarting the following units: polkit.service
    the following new units were started: libvirtd.service
    
  25. primeos commented on Nov 28, 2021

    @primeos
    Member

    One thing I am wondering is what the exact conditions are to trigger this issue.

    The relevant socket units have to change between the old and new revision / NixOS generation.

    We've been running this change on close to 70 different system configurations deployed to a couple of hundred devices that are headless, using i3, or a full KDE environment and nothing ever happened.

    Strange. Was that on nixos-unstable and two Nixpkgs revisions that differ significantly enough so that many units get restarted?

    Does anyone have the switch-to-configuration output for an affected system?

    TODO: I'll have to grab my logs later and put them into a Gist.
    Update: Here are my personal logs from testing on a secondary system with Sway: https://gist.github.com/primeos/604b516a843dfcadc2e816b02a271e7e (only BAD-REVISION-1 -> GOOD-REVISION-1 was fine)

    The following additional units got:

    • Stopped: dbus.service', 'systemd-journald.service', 'wpa_supplicant.service'
    • Restarted: cups.socket', 'dbus.socket', 'fstrim.timer', 'libvirtd-admin.socket', 'libvirtd-ro.socket', 'libvirtd.socket', 'nix-daemon.socket', 'pcscd.socket', 'systemd-coredump.socket', 'systemd-journald-audit.socket', 'systemd-journald-dev-log.socket', 'systemd-journald.socket', 'systemd-rfkill.socket', 'systemd-tmpfiles-clean.timer', 'systemd-udevd-control.socket', 'systemd-udevd-kernel.socket', 'virtlockd.socket', 'virtlogd.socket'
      **Edit: I expected more but if my allowlist changes are correct it might just be due to dbus.service (I'm quite surprised that only dbus, systemd-journald, and wpa_supplicant were restarted).

    If not there's not really a lot I can do because I am unable to reproduce this.

    Should at least be consistently reproducible with Sway.

    Edit the systemd-logind assumption from discourse seems to be wrong. When I change my logind unit, no logind and hence no i3 is restarted:

    Not sure if there's just one or multiple causes but I've seen e.g. D-Bus restarted which seems very problematic to me.

    PS: Sorry if my replies are a bit direct, I just have to keep it short due to time constraints.

    Edit: I've also got the following at the end of nixos-rebuild switch:

    org.freedesktop.DBus.Error.Disconnected: Connection was disconnected before a reply was received
    warning: error(s) occurred while switching to the new configuration
    
  26. added a commit that references this issue on Nov 29, 2021
    8e8a439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug6.topic: nixos

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions