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
21.95k stars 912 forks source link

Dragging any Unity Application Across Displays Crashes Hyprland #5344

Open Sewer56 opened 8 months ago

Sewer56 commented 8 months ago

Hyprland Version

System/Version info ```sh Hyprland, built from branch HEAD at commit c5e28ebcfe00a510922779b2c568cfa52a317445 (props: bump ver 0.37.1). Date: Sat Mar 16 14:51:49 2024 Tag: v0.37.1 flags: (if any) System Information: System name: Linux Node name: sewer-cachyos Release: 6.8.2-2-cachyos Version: #1 SMP PREEMPT_DYNAMIC Wed, 27 Mar 2024 20:22:36 +0000 GPU information: 26:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] [10de:1b06] (rev a1) (prog-if 00 [VGA controller]) os-release: NAME="CachyOS Linux" PRETTY_NAME="CachyOS" ID=cachyos ID_LIKE=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://cachyos.org/" DOCUMENTATION_URL="https://wiki.cachyos.org/" SUPPORT_URL="https://forum.cachyos.org/" BUG_REPORT_URL="https://github.com/cachyos" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=cachyos plugins: ```

Bug or Regression?

Bug

Description

Dragging a Unity application across displays with the mouse causes a Hyprland crash. (Happens on all Unity applications I've tested so far)

My displays are configured as

monitor=DVI-D-1,1920x1080@144.0,2560x0,1.0
monitor=DP-1,3840x2160@60.0,0x0,1.5000000000000004

i.e. 3840x2160@60Hz panel on the left, 1920x1080@144Hz on the right.

Issue is not related to display scaling, I've tried setting both monitors to 1.0, and still experienced it.

How to reproduce

When this happens, second display that the application's being dragged onto will show only wallpaper (same behaviour as when fullscreen application is enabled).


Note: This crash only occurs when using mouse. Moving windows across displays with keyboard works fine.

Crash reports, logs, images, videos

hyprlandCrashReport165379.txt hyprlandCrashReport182955.txt

Two crash reports for two separate unity programs. One is running under Wine, the other is native.


Edit: Updated opening post, as this seems to occur in native Linux Unity applications too.

vaxerski commented 8 months ago

can you try on git

Sewer56 commented 8 months ago

Yeah no sweat, I'll build and see when I get back home.

Sewer56 commented 8 months ago

hyprlandCrashReport868.txt

Here's a report on latest git build (8cb38d41d203f95ea9c2be79996a5f0deda3eabf).

I haven't debugged into it, but if I were to guess, part of the cause would be Unity applications trying to constantly enter fullscreen, even when you set the window to floating.

vaxerski commented 8 months ago

suppressevent fullscreen maximize windowrule helps

can you build hyprland in debug? many frames are skipped... this is odd.

Sewer56 commented 8 months ago

hyprlandCrashReport874.txt

I built the AUR package with --buildtype debug and -D b_lto=false. Conversely it then read from hyprlandd.conf, as expected.

Hopefully that gets rid of some inlining for a more readable stack trace.


Also yup, suppressing fullscreen avoids the issue.

vaxerski commented 8 months ago
    #4 | Hyprland(+0xb1865) [0x646f276a9865]
        CCompositor::setPreferredTransformForSurface(wlr_surface*, wl_output_transform)
        ??:?
    #5 | Hyprland(_ZN18CHyprDwindleLayout18calculateWorkspaceERKi+0x2b5) [0x646f2776a555]
        CHyprDwindleLayout::calculateWorkspace(int const&)
        ??:?

How? calculateWorkspace doesn't call setPreferredTransformForSurface at all and I can't see a path where it could. Does gdb with bt -full show something else?

Sewer56 commented 8 months ago

(Note: I've only been daily driving Linux for ~8 months after a many year hiatus, and I don't do C++ often, so debugging low level native dev stuff on Linux is in some facets unfamiliar to me.)


Anyway, I was thinking. Maybe the backtrace was inaccurate because creating an Arch package strips symbols.

I come from a background of modding native games (albeit NOT with C/C++, am a rebel), and seeing functions misattributed when there is minimal debug info is pretty common.

So I built the package completely from source, and did a manual install, just in case

hyprlandCrashReport871.txt

This stack trace points at

https://github.com/hyprwm/Hyprland/blob/db1506130b507f92e0daf3a36495fb985e242bbc/src/layout/DwindleLayout.cpp#L578-L583

The culprit seems to be PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;. Which then eventually winds up calling Vector2D's == operator down the road.

Given the the crash is a segfault (i.e. access violation), I'd guess that one of the vector references are invalid. I could maybe try looking at the ASM and figure out which.

Given Unity applications are constantly trying to go fullscreen, maybe there's a race condition somewhere under the hood.

Does gdb with bt -full show something else?

Do you still want this? I assume you want me to open a TTY and gdb attach from it when Hyprland is in another TTY, and just dump whatever I get on crash.

Sewer56 commented 8 months ago
                     **************************************************************
                     * Vector2D::TEMPNAMEPLACEHOLDERVALUE(Vector2D const&) const  *
                     **************************************************************
                     undefined __thiscall operator==(Vector2D * this, Vector2
     undefined         AL:1           <RETURN>
     Vector2D *        RDI:8 (auto)   this
     Vector2D *        RSI:8          param_1
                     _ZNK8Vector2DeqERKS_                            XREF[26]:    Entry Point(*), 
                     Vector2D::operator==                                         operator=:00408042(c), 
                                                                                  onMouseMove:0059ece5(c), 
                                                                                  setValue:005a39c4(c), 
                                                                                  operator():005b794c(c), 
                                                                                  setWindowSize:005fc457(c), 
                                                                                  setWindowSize:005fc478(c), 
                                                                                  setWindowSize:005fc49c(c), 
                                                                                  mouseMoveUnified:006039e5(c), 
                                                                                  mouseMoveUnified:00604dfc(c), 
                                                                                  begin:0067c81d(c), 
                                                                                  calculateUVForSurface:006a2281(c
                                                                                  calculateUVForSurface:006a22d4(c
                                                                                  applyMonitorRule:006aa1d9(c), 
                                                                                  applyMonitorRule:006ab3ed(c), 
                                                                                  applyMonitorRule:006ac21e(c), 
                                                                                  applyMonitorRule:006ac3b1(c), 
                                                                                  applyMonitorRule:006ac41a(c), 
                                                                                  onWindowUpdate:006cf624(c), 
                                                                                  007ae5b8, [more]
003f1bae 55              PUSH       RBP
003f1baf 48 89 e5        MOV        RBP,RSP
003f1bb2 48 89 7d f8     MOV        qword ptr [RBP + -0x8],this
003f1bb6 48 89 75 f0     MOV        qword ptr [RBP + -0x10],param_1
003f1bba 48 8b 45 f0     MOV        RAX,qword ptr [RBP + -0x10]
003f1bbe f2 0f 10 00     MOVSD      XMM0,qword ptr [RAX]

I don't know what's the 'normal' way of debugging things like this, but I opened my self built binary into Ghidra (which I happen to have installed) and looked at the instruction causing the crash (003f1bbe), which I got from the stacktrace.

It seems the crash is caused by m_Goal (RSI, SystemV Call Convention) being null here. Assuming that v becomes the this parameter in v == m_Goal. (see: CAnimatedVariable& operator=)

acheong08 commented 6 months ago

@Sewer56 Have you found any workarounds? I'm also getting crashes on startup with ghidra in lastest git

Sewer56 commented 6 months ago

No, not in code anyway. I haven't looked into how to fix it. I only identified the underlying crash reason to a line. I've been extremely busy maintaining OSS software in all of my spare time.

I'm probably as bad as Vaxry when it comes to 'touching grass'.

Sewer56 commented 6 months ago

@acheong08 But as suggested earlier by Vaxry, a temporary workaround that does not require code is to suppress application requested resize events. In the case of Unity that's suppressevent fullscreen maximize

acheong08 commented 6 months ago

Indeed that worked. It feels like Hyprland has gotten a bit more buggy since v0.40.0. I wonder if having hyprland implementations is taking a bit of a toll