swaylock icon indicating copy to clipboard operation
swaylock copied to clipboard

Debian version of swaylock (based on v1.5) in bullseye (currently testing branch) crashing

Open mirko opened this issue 3 years ago • 12 comments

In my current setup swaylock crashes for me when waking up my computer. I see the ring, start typing and even before hitting the second key I already see my desktop - and swaylock having crashed in the logs.

I know it's not swaylock vanilla, though the 3 patches applied to the source for the debian package don't seem invasive (http://deb.debian.org/debian/pool/main/s/swaylock/swaylock_1.5-2.debian.tar.xz) and since its single purpose is to lock the screen which it fails to do so in my case, I allow myself to also report it here.

$ gdb /usr/bin/swaylock swaylock 
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/swaylock...
(No debugging symbols found in /usr/bin/swaylock)

warning: Can't open file /run/user/1000/sway-client-MEyRWr (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-aEXPHq (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-t7pXbt (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-WDUIWr (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-ME2Avt (deleted) during file-backed mapping note processing
[New LWP 4077683]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `swaylock -c 000000'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) thread apply all bt

Thread 1 (Thread 0x7f291a2bcfc0 (LWP 4077683)):
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f291b1f8537 in __GI_abort () at abort.c:79
#2  0x00007f291b251768 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f291b35fe2d "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007f291b258a5a in malloc_printerr (str=str@entry=0x7f291b362110 "malloc_consolidate(): invalid chunk size") at malloc.c:5347
#4  0x00007f291b259918 in malloc_consolidate (av=av@entry=0x7f291b391b80 <main_arena>) at malloc.c:4477
#5  0x00007f291b25b755 in _int_malloc (av=av@entry=0x7f291b391b80 <main_arena>, bytes=bytes@entry=3584) at malloc.c:3699
#6  0x00007f291b25d164 in __GI___libc_malloc (bytes=3584) at malloc.c:3058
#7  0x00007f291b4dafae in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#8  0x00007f291b4dbce4 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#9  0x00007f291b4c2dab in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#10 0x00007f291b4eb4d7 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#11 0x00007f291b4eb427 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#12 0x00007f291b4eb40c in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#13 0x00007f291b4eb40c in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#14 0x00007f291b4eb40c in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#15 0x00007f291b4eb7d0 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#16 0x00007f291b4c2e3c in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#17 0x00007f291b4c495a in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#18 0x00007f291b4c30a5 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#19 0x00007f291b4e9d16 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#20 0x00007f291b4a541e in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#21 0x00007f291b4b7825 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#22 0x00007f291b4f685e in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#23 0x00007f291b4add75 in ?? () from /lib/x86_64-linux-gnu/libcairo.so.2
#24 0x00007f291b5040da in cairo_fill_preserve () from /lib/x86_64-linux-gnu/libcairo.so.2
#25 0x0000562274d7dd29 in ?? ()
#26 0x0000562274d7c81a in ?? ()
#27 0x00007f291a7a4d1d in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#28 0x00007f291a7a4289 in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#29 0x00007f291b3b52d2 in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#30 0x00007f291b3b197a in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#31 0x00007f291b3b303c in wl_display_dispatch_queue_pending () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#32 0x0000562274d7b9a0 in ?? ()
#33 0x0000562274d7b79f in ?? ()
#34 0x0000562274d79eb5 in ?? ()
#35 0x00007f291b1f9d0a in __libc_start_main (main=0x562274d79900, argc=3, argv=0x7ffffaa35588, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffffaa35578) at ../csu/libc-start.c:308
#36 0x0000562274d7a35a in ?? ()
(gdb)

mirko avatar Jun 28 '21 21:06 mirko

Please reproduce with a manually compiled swaylock and post the new stack trace.

emersion avatar Jun 28 '21 21:06 emersion

Please reproduce with a manually compiled swaylock and post the new stack trace.

I won't be able to do so on this very machine - at least not immediately.

For the record, a backtrace with debug symbols installed/resolved:

$ gdb /usr/bin/swaylock swaylock.dbg.coredump 
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/swaylock...
Reading symbols from /usr/lib/debug/.build-id/e4/a2b3023af52ea7db8335973295081c0eefbc8e.debug...

warning: Can't open file /run/user/1000/sway-client-2tGGCz (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-a3xSbA (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-ecJ0CB (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-hQPSFB (deleted) during file-backed mapping note processing

warning: Can't open file /dev/shm/wlroots-bEmopO (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/sway-client-L9TnHC (deleted) during file-backed mapping note processing
[New LWP 10929]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `swaylock -c 000000'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f7e4788a537 in __GI_abort () at abort.c:79
#2  0x00007f7e478e3768 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f7e479f1e2d "%s\n")
    at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007f7e478eaa5a in malloc_printerr (str=str@entry=0x7f7e479f4110 "malloc_consolidate(): invalid chunk size")
    at malloc.c:5347
#4  0x00007f7e478eb918 in malloc_consolidate (av=av@entry=0x7f7e47a23b80 <main_arena>) at malloc.c:4477
#5  0x00007f7e478ed755 in _int_malloc (av=av@entry=0x7f7e47a23b80 <main_arena>, bytes=bytes@entry=1424) at malloc.c:3699
#6  0x00007f7e478efed1 in __libc_calloc (n=n@entry=1, elem_size=elem_size@entry=1424) at malloc.c:3428
#7  0x00007f7e47a6d51e in xkb_keymap_new (ctx=0x55b410184f90, format=format@entry=XKB_KEYMAP_FORMAT_TEXT_V1, 
    flags=flags@entry=XKB_KEYMAP_COMPILE_NO_FLAGS) at ../src/keymap-priv.c:62
#8  0x00007f7e47a6cd36 in xkb_keymap_new_from_buffer (ctx=<optimized out>, 
    buffer=buffer@entry=0x7f7e46942000 "xkb_keymap {\nxkb_keycodes \"(unnamed)\" {\n\tminimum = 8;\n\tmaximum = 569;\n\t<ESC>", ' ' <repeats 16 times>, "= 9;\n\t<AE01>", ' ' <repeats 15 times>, "= 10;\n\t<AE02>", ' ' <repeats 15 times>, "= 11;\n\t<AE03>", ' ' <repeats 15 times>, "= 12;\n\t<AE04>", ' ' <repeats 12 times>..., length=49092, 
    format=format@entry=XKB_KEYMAP_FORMAT_TEXT_V1, flags=flags@entry=XKB_KEYMAP_COMPILE_NO_FLAGS) at ../src/keymap.c:193
#9  0x00007f7e47a6ce1b in xkb_keymap_new_from_string (ctx=<optimized out>, 
    string=string@entry=0x7f7e46942000 "xkb_keymap {\nxkb_keycodes \"(unnamed)\" {\n\tminimum = 8;\n\tmaximum = 569;\n\t<ESC>", ' ' <repeats 16 times>, "= 9;\n\t<AE01>", ' ' <repeats 15 times>, "= 10;\n\t<AE02>", ' ' <repeats 15 times>, "= 11;\n\t<AE03>", ' ' <repeats 15 times>, "= 12;\n\t<AE04>", ' ' <repeats 12 times>..., format=format@entry=XKB_KEYMAP_FORMAT_TEXT_V1, 
    flags=flags@entry=XKB_KEYMAP_COMPILE_NO_FLAGS) at ../src/keymap.c:164
#10 0x000055b40f14874b in keyboard_keymap (data=0x55b40f14f900 <state>, wl_keyboard=<optimized out>, format=<optimized out>, 
    fd=6, size=49093) at ../seat.c:24
#11 0x00007f7e46e36d1d in ffi_call_unix64 () at ../src/x86/unix64.S:101
#12 0x00007f7e46e36289 in ffi_call_int (cif=0x7ffef714cb60, fn=0x55b40f1486f0 <keyboard_keymap>, rvalue=<optimized out>, 
    avalue=<optimized out>, closure=<optimized out>) at ../src/x86/ffi64.c:669
#13 0x00007f7e47a472d2 in wl_closure_invoke (closure=closure@entry=0x55b4102038f0, flags=flags@entry=1, 
    target=<optimized out>, target@entry=0x55b41018b4c0, opcode=opcode@entry=0, data=<optimized out>)
    at ../src/connection.c:1018
#14 0x00007f7e47a4397a in dispatch_event (display=display@entry=0x55b410185860, queue=<optimized out>, queue=<optimized out>)
    at ../src/wayland-client.c:1445
#15 0x00007f7e47a4503c in dispatch_queue (queue=0x55b410185930, display=0x55b410185860) at ../src/wayland-client.c:1591
#16 wl_display_dispatch_queue_pending (display=0x55b410185860, queue=0x55b410185930) at ../src/wayland-client.c:1833
#17 0x000055b40f1459a0 in display_in (fd=<optimized out>, mask=<optimized out>, data=<optimized out>) at ../main.c:1080
#18 0x000055b40f14579f in loop_poll (loop=0x55b4101d1f30) at ../loop.c:95
#19 0x000055b40f143eb5 in main (argc=3, argv=0x7ffef714cfc8) at ../main.c:1235

mirko avatar Jun 29 '21 15:06 mirko

Sounds like https://github.com/swaywm/swaylock/issues/181

savchenko avatar Jul 14 '21 01:07 savchenko

Can you try running with ASan? This smells like memory corruption.

emersion avatar Jul 29 '21 07:07 emersion

(See closed issue Github automatically linked above) I have built with meson build/ -Db_sanitize=address,undefined and will the use the resulting binary for some time in an attempt to get more information. In order to capture the output I am going to run swaylock like swaylock &| tee swaylock.log. Let me know if I should change anything.

Already I see without a crash a couple of memory leaks like

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7f75f6ace279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f75f5883255  (/usr/lib/libfontconfig.so.1+0x21255)

I think this is benign and happens because for leak detection to work properly libraries would have to be compiled with asan as well. Mentioning it just in case.

e00E avatar Jul 30 '21 08:07 e00E

So far I have not encountered a crash on master. If I do I will post again.

e00E avatar Aug 04 '21 07:08 e00E

Sounds encouraging. Could you upload the binar(y|ies)? Happy to test.

savchenko avatar Aug 04 '21 07:08 savchenko

I just compiled with the instructions in the readme with the extra options to meson build. It is easy to compile and my binaries probably won't work on other systems anyway (not sure if they are static). So I think it it is better if you try building yourself.

e00E avatar Aug 04 '21 12:08 e00E

Hi,

Same issue with swaylock-1.5-2 as shipped by Ubuntu 21.04. Recompiled from master branch: crash when secondary monitor wakes up seem to be solved!

cmaion avatar Aug 14 '21 16:08 cmaion

swaylock built on Debian 11:

meson build/ -Db_sanitize=address,undefined

Upon exit:

==196107==LeakSanitizer has encountered a fatal error.
==196107==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==196107==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
==196108==LeakSanitizer has encountered a fatal error.
==196108==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==196108==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)

savchenko avatar Aug 18 '21 07:08 savchenko

Update, with the same binary, when laptop left connected to an external monitor via USB-C, swaylock gets "stuck" consuming 100% of the single core. It does not respond to any user input and shows no widgets on the screen. The only way out was to kill it from another TTY.

savchenko avatar Aug 19 '21 07:08 savchenko

Another update, I can reproduce the same when running Sway v1.6. Installed from experimental together with:

Package: libwayland-client0
Version: 1.19.0-2

Package: libwayland-cursor0
Version: 1.19.0-2

Package: libwlroots8
Version: 0.13.0-1

Package: libwayland-server0
Version: 1.19.0-2

savchenko avatar Aug 29 '21 01:08 savchenko