swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.33k stars 1.09k forks source link

DPMS resume triggers xdg_toplevel.configure with negative size #7505

Open japalvia opened 1 year ago

japalvia commented 1 year ago

Please fill out the following:

zsh:

Core was generated by `/bin/zsh'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44        return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f1f1d9b7953 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007f1f1d968ea8 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f1f1d95253d in __GI_abort () at abort.c:79
#4  0x00007f1f1d95329e in __libc_message (fmt=fmt@entry=0x7f1f1daca77e "%s\n") at ../sysdeps/posix/libc_fatal.c:150
#5  0x00007f1f1d9c1657 in malloc_printerr (str=str@entry=0x7f1f1dac81d9 "corrupted size vs. prev_size") at malloc.c:5651
#6  0x00007f1f1d9c215e in unlink_chunk (p=<optimized out>, av=0x7f1f1db08aa0 <main_arena>) at malloc.c:1605
#7  0x00007f1f1d9c22d0 in malloc_consolidate (av=av@entry=0x7f1f1db08aa0 <main_arena>) at malloc.c:4766
#8  0x00007f1f1d9c47d0 in _int_malloc (av=av@entry=0x7f1f1db08aa0 <main_arena>, bytes=3088) at malloc.c:3951
#9  0x00007f1f1d9c59f2 in __GI___libc_malloc (bytes=<optimized out>) at malloc.c:3297
#10 0x0000559963a830d8 in zalloc (size=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/mem.c:966
#11 0x00007f1f1d5d36c2 in resetvideo () at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_refresh.c:776
#12 0x00007f1f1d5da738 in zrefresh () at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_refresh.c:1201
#13 0x00007f1f1d5cfd8e in zle_main_entry (cmd=<optimized out>, ap=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_main.c:2146
#14 0x0000559963a76854 in zleentry (cmd=5) at /usr/src/debug/zsh/zsh-5.9/Src/init.c:1631
#15 0x0000559963ab8483 in zhandler (sig=28) at /usr/src/debug/zsh/zsh-5.9/Src/signals.c:687
#16 <signal handler called>
#17 0x00007f1f1da26931 in __GI___libc_read (fd=10, buf=buf@entry=0x7ffd0872ff9f, nbytes=nbytes@entry=1) at ../sysdeps/unix/sysv/linux/read.c:26
#18 0x00007f1f1d5c73dc in read (__nbytes=1, __buf=0x7ffd0872ff9f, __fd=<optimized out>) at /usr/include/bits/unistd.h:38
#19 raw_getbyte (full=1, cptr=0x7ffd0872ff9f "", do_keytmout=0) at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_main.c:849
#20 getbyte (do_keytmout=do_keytmout@entry=0, timeout=timeout@entry=0x0, full=full@entry=1) at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_main.c:884
#21 0x00007f1f1d5c7cb1 in getkeybuf (w=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_keymap.c:1696
#22 getkeymapcmd (km=0x55996403df10, funcp=funcp@entry=0x7ffd08730310, strp=strp@entry=0x7ffd08730308) at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_keymap.c:1607
#23 0x00007f1f1d5ca819 in getkeycmd () at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_keymap.c:1725
#24 0x00007f1f1d5cd70d in zlecore () at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_main.c:1134
#25 0x00007f1f1d5ce514 in zleread (lp=<optimized out>, rp=<optimized out>, flags=<optimized out>, context=0, init=0x7f1f1d5ed39a "zle-line-init", finish=0x7f1f1d5ed38a "zle-line-finish")
    at /usr/src/debug/zsh/zsh-5.9/Src/Zle/zle_main.c:1356
#26 0x0000559963a76854 in zleentry (cmd=cmd@entry=1) at /usr/src/debug/zsh/zsh-5.9/Src/init.c:1631
#27 0x0000559963a770d6 in inputline () at /usr/src/debug/zsh/zsh-5.9/Src/input.c:424
#28 ingetc () at /usr/src/debug/zsh/zsh-5.9/Src/input.c:357
#29 ingetc () at /usr/src/debug/zsh/zsh-5.9/Src/input.c:321
#30 0x0000559963a69fc4 in ihgetc () at /usr/src/debug/zsh/zsh-5.9/Src/hist.c:415
#31 0x0000559963a84e3f in gettok () at /usr/src/debug/zsh/zsh-5.9/Src/lex.c:622
#32 zshlex () at /usr/src/debug/zsh/zsh-5.9/Src/lex.c:275
#33 0x0000559963aa7ac8 in zshlex () at /usr/src/debug/zsh/zsh-5.9/Src/lex.c:268
#34 parse_event (endtok=37) at /usr/src/debug/zsh/zsh-5.9/Src/parse.c:615
#35 0x0000559963a703b6 in loop (toplevel=toplevel@entry=1, justonce=justonce@entry=0) at /usr/src/debug/zsh/zsh-5.9/Src/init.c:150
#36 0x0000559963a78845 in zsh_main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/init.c:1794
#37 0x0000559963a270ee in main (argc=<optimized out>, argv=<optimized out>) at ./main.c:93

Steps to reproduce in my system:

  1. Start terminal with zsh shell: alacritty -e zsh
  2. In the new terminal, start calculator: bc
  3. Turn off and on the display: swaymsg "output * dpms off" ; sleep 10 ; swaymsg "output * dpms on"

Expected result: after display resumes, bc and zsh are running without issues Actual result: bc crashes (100 % reproducible), zsh crashes frequently

I reported this first to https://github.com/alacritty/alacritty/issues/6773 where the following error was observed in WAYLAND_DEBUG=client logs:

3923471.427] xdg_toplevel@30.configure(-4, -27, array[16])

Other ways to crash zsh after resume: Type "journalc" and complete with Tab --> immediate crash.

The crash is not specific to zsh. I used to get this randomly with bash after dpms. I think I've had this since moving to Wayland and alacritty (~ 2 years).

I cannot reproduce using urxvt or kitty. Also, I cannot reproduce this issue in Weston.

Other info: This setup is Intel NUC with DELL U3818DW on HDMI. There's no additional display configuration tool like kanshi on this machine. I have identical installation on a laptop with external 4K display (using kanshi) where the issue doesn't seem to happen ever.

YellowOnion commented 1 year ago

Is your monitor plugged in to Display Port? This might be related to some serious issue with Rapid Hotplug Detect or Deep sleep spec and about 50% of monitor manufactures not reading the spec correctly, or Linux not handling it correctly.

https://www.theverge.com/2021/4/28/22407995/microsoft-windows-apps-rearranging-sleep-resume-fix-directx-12

https://www.reddit.com/r/nvidia/comments/66opvp/this_displayport_hotplug_madness_finally_needs_to/

japalvia commented 1 year ago

Is your monitor plugged in to Display Port?

I'm using HDMI (this NUC model doesn't have DP). There's only Intel GPU if that's relevant info.