hyprlock icon indicating copy to clipboard operation
hyprlock copied to clipboard

[bug] series of repeated key presses crashes and unlocks

Open jpeeler opened this issue 1 year ago • 5 comments

After monitors power off, if I press a key repeatedly as the monitors are powering up (say shift 10 times) screen turns red and then unlocks. I'm hoping that this is easily reproducible.

I'm using hyprlock 0.3.0, but the bug was present in the last release as well.

hypridle.conf:

general {
    lock_cmd = pidof hyprlock || hyprlock
    before_sleep_cmd = loginctl lock-session
    after_sleep_cmd = hyprctl dispatch dpms on
    ignore_dbus_inhibit = false
}

listener {
   timeout = 900
   on-timeout = loginctl lock-session
}

listener {
    timeout = 1200
    on-timeout = hyprctl dispatch dpms off
    on-resume = hyprctl dispatch dpms on
}

Not sure how helpful this stack trace is:

             Stack trace of thread 135738:
                #0  0x00007f3ba6eae834 __pthread_kill_implementation (libc.so.6 + 0x90834)
                #1  0x00007f3ba6e5c8ee raise (libc.so.6 + 0x3e8ee)
                #2  0x00007f3ba6e4498f abort (libc.so.6 + 0x2698f)
                #3  0x000055e2b3ec2505 _ZL20handleCriticalSignali (hyprlock + 0x29505)
                #4  0x00007f3ba6e5c9a0 __restore_rt (libc.so.6 + 0x3e9a0)
                #5  0x000055e2b3ec6ee5 _ZN19CSessionLockSurface6renderEv (hyprlock + 0x2dee5)
                #6  0x000055e2b3ec7c43 _ZN9CHyprlock5onKeyEjb (hyprlock + 0x2ec43)
                #7  0x00007f3ba6a14056 ffi_call_unix64 (libffi.so.8 + 0x9056)
                #8  0x00007f3ba6a105ef ffi_call_int.lto_priv.0 (libffi.so.8 + 0x55ef)
                #9  0x00007f3ba6a133fe ffi_call (libffi.so.8 + 0x83fe)
                #10 0x00007f3ba7422f0e wl_closure_invoke.constprop.0 (libwayland-client.so.0 + 0x7f0e)
                #11 0x00007f3ba7423793 dispatch_event.isra.0 (libwayland-client.so.0 + 0x8793)
                #12 0x00007f3ba7423a3c wl_display_dispatch_queue_pending (libwayland-client.so.0 + 0x8a3c)
                #13 0x000055e2b3ecb3da _ZN9CHyprlock3runEv (hyprlock + 0x323da)
                #14 0x000055e2b3eb0073 main (hyprlock + 0x17073)
                #15 0x00007f3ba6e4614a __libc_start_call_main (libc.so.6 + 0x2814a)
                #16 0x00007f3ba6e4620b __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2820b)
                #17 0x000055e2b3eb1985 _start (hyprlock + 0x18985)

jpeeler avatar Apr 09 '24 20:04 jpeeler

I think it probably unlocks because of the grace period. Do you have grace set?

Because when hyprlock crashes it will try to recover by restaring hyprlock. Otherwise you would be stuck with the red screen and until now i think we missed that grace is a problem when doing that.

PointerDilemma avatar Apr 10 '24 05:04 PointerDilemma

But sadly I am not able to reproduce the crash when monitors are turning back on.

PointerDilemma avatar Apr 10 '24 06:04 PointerDilemma

Sorry I should have also included hyprlock.conf, I do have the grace period set:

general {
	grace = 10
}

background {
    monitor =
	path = screenshot
    color = rgba(135, 135, 135, 1.0)

    # all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations
    blur_passes = 2 # 0 disables blurring
    blur_size = 7
    noise = 0.0117
    contrast = 0.8916
    brightness = 0.8172
    vibrancy = 0.1696
    vibrancy_darkness = 0.0
}

input-field {
    monitor =
    size = 500, 50
    outline_thickness = 3
    dots_size = 0.33 # Scale of input-field height, 0.2 - 0.8
    dots_spacing = 0.15 # Scale of dots' absolute size, 0.0 - 1.0
    dots_center = false
    outer_color = rgb(151515)
    inner_color = rgb(200, 200, 200)
    font_color = rgb(10, 10, 10)
    fade_on_empty = true
    placeholder_text = <i>Input Password...</i> # Text rendered in the input box when it's empty.
    hide_input = true

    position = 0, -20
    halign = center
    valign = center
}


label {
    monitor =
    text = Hi there, $USER
    color = rgba(200, 200, 200, 1.0)
    font_size = 25
    font_family = Noto Sans

    position = 0, 180
    halign = center
    valign = center
}

label {
    monitor =
	text = $TIME
    color = rgba(200, 200, 200, 1.0)
    font_size = 25
    font_family = Noto Sans

    position = 0, 80
    halign = center
    valign = center
}

Would be great if this part was fixed too now that the "backdoor" has probably been fixed :smile:

jpeeler avatar Apr 10 '24 14:04 jpeeler

But sadly I am not able to reproduce the crash when monitors are turning back on.

Also tried to reproduce this (fresh git clone & install) and cannot reproduce it (without grace period).

DiskyToy avatar Apr 10 '24 14:04 DiskyToy

Could it be related to incorrect memory address for frameCallback?

https://github.com/hyprwm/hyprlock/blob/c87af3aa1f6e6bd06cffaabcc400bd45e26d565a/src/core/LockSurface.cpp#L129-L142

Valgrind output:

==23669== 1 errors in context 1 of 1:
==23669== Invalid read of size 8
==23669==    at 0x4318C2: CSessionLockSurface::render() (LockSurface.cpp:132)
==23669==    by 0x43C1C0: CHyprlock::onKey(unsigned int, bool) (hyprlock.cpp:867)
==23669==    by 0x43B1F1: handleKeyboardKey(void*, wl_keyboard*, unsigned int, unsigned int, unsigned int, unsigned int) (hyprlock.cpp:674)
==23669==    by 0x5845055: ffi_call_unix64 (unix64.S:104)
==23669==    by 0x584169F: ffi_call_int.lto_priv.0 (ffi64.c:673)
==23669==    by 0x58444ED: ffi_call (ffi64.c:710)
==23669==    by 0x4F09F2D: wl_closure_invoke.constprop.0 (connection.c:1025)
==23669==    by 0x4F0A7A2: dispatch_event.isra.0 (wayland-client.c:1631)
==23669==    by 0x4F0AA4B: UnknownInlinedFun (wayland-client.c:1777)
==23669==    by 0x4F0AA4B: wl_display_dispatch_queue_pending (wayland-client.c:2019)
==23669==    by 0x43A173: CHyprlock::run() (hyprlock.cpp:482)
==23669==    by 0x44C8DF: main (main.cpp:55)
==23669==  Address 0x70 is not stack'd, malloc'd or (recently) free'd

valgrind-out-native2.txt

jpeeler avatar May 04 '24 23:05 jpeeler