hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
18.57k stars 772 forks source link

Hyprland cannot handle concurrent addition/removal of monitors #6207

Open realSaltyFish opened 2 months ago

realSaltyFish commented 2 months ago

Hyprland Version

System/Version info ```sh Hyprland, built from branch at commit cba1ade848feac44b2eda677503900639581c3f4 (props: bump version to 0.40.0). Date: Sat May 4 15:42:32 2024 Tag: v0.40.0, commits: 4606 flags: (if any) System Information: System name: Linux Node name: saltybook Release: 6.3.8-arch1-1 Version: #1 SMP PREEMPT_DYNAMIC Wed, 14 Jun 2023 20:10:31 +0000 GPU information: 00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics] [8086:46a6] (rev 0c) (prog-if 00 [VGA controller]) DeviceName: Second VGA os-release: NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo plugins: split-monitor-workspaces by Duckonaut ver 1.1.0 ```

Bug or Regression?

Bug

Description

I have two external monitors connected through a dock to my laptop. When I plug/unplug the dock, depending on Hyprland version and luck, these things could happen randomly:

This looks very nondeterministic, so I think it's likely synchronization-related (internal data structure corrupt?). Everything is good if I plug/unplug the monitors one by one.

BTW, I cloned Hyprland and played around. I made a debug build but its crash reports do not include a stack trace. Core dump files do not have line numbers and symbol information (all function calls are shown as question marks), so was not really helpful for my investigation. Did I miss something?

How to reproduce

Use 0.40.0 or latest commit. This is reproducible with default configuration.

  1. Launch Hyprland.
  2. Plug in a dock with two monitors connected to it.
  3. If everything works, unplug the dock.
  4. If everything works, plug it back in.
  5. Repeat until it breaks. It's unlikely that the issue doesn't manifest by this point though.

Crash reports, logs, images, videos

hyprlandCrashReport47616.txt hyprlandCrashReport469023.txt I attached two crash reports. One of them segfaulted because of an IPC call. My AGS bar uses IPC to get workspace info from Hyprland. I restarted Hyprland without the bar running, and got the other crash report which failed on something else.

This issue is very versatile and I don't know what else I should upload here. I did a ton of testing and got a ton of log files and crash reports. Let me know if you are interested in any specific scenarios. I'll do my best to gather more specific info.

realSaltyFish commented 2 months ago

https://github.com/hyprwm/Hyprland/blob/7ad9116de8d0b7dac27eaf080bd92998a8fb40e5/src/events/Monitors.cpp#L53

A quick brief look at this function suggests that this callback function calls std::vector::emplace_back(), which is not thread-safe. Not sure if this is the actual problem though. I haven't written C++ in a while and am getting a bit rusty on it.

vaxerski commented 2 months ago

the event loop is single-threaded