Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kitty segfaults when pasting in some programs under KDE Plasma on Wayland #5603

Closed
saucyfox opened this issue Oct 18, 2022 · 7 comments
Closed
Labels

Comments

@saucyfox
Copy link

saucyfox commented Oct 18, 2022

Describe the bug
kitty crashes when I copy text from the terminal and paste into some programs (pasting within kitty works fine). I'm using it in a KDE Plasma session under Wayland on Arch. So far I've observed the behavior with Firefox and LibreOffice. Pasting within the Kate editor works fine, strangely, and I've verified that all of these are running under wayland (and not xwayland) by checking with xwininfo.

I'm honestly not sure whether this is a bug in kitty, plasma, or the programs I'm pasting to, but kitty is the only application I've noticed this behavior with.

To Reproduce
Steps to reproduce the behavior:

  1. Select some text in kitty and copy it.
  2. Paste in Firefox.
  3. kitty segfaults with the error message Aborted (core dumped)

Environment details

kitty 0.26.3 created by Kovid Goyal
Linux hostname 6.0.2-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sat, 15 Oct 2022 14:00:51 +0000 x86_64
Arch Linux 6.0.2-zen1-1-zen (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: Wayland
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/bash
Loaded config files:
  /home/username/.config/kitty/kitty.conf

Config options different from defaults:
cursor_text_color       None
font_family             Hack
font_size               10.0
Colors:
	active_tab_background   #f8f8f2   
	active_tab_foreground   #282a36   
	background              #282a36   
	color0                  #21222c   
	color1                  #ff5555   
	color10                 #69ff94   
	color11                 #ffffa5   
	color12                 #d6acff   
	color13                 #ff92df   
	color14                 #a4ffff   
	color2                  #50fa7b   
	color3                  #f1fa8c   
	color4                  #bd93f9   
	color5                  #ff79c6   
	color6                  #8be9fd   
	color7                  #f8f8f2   
	color8                  #6272a4   
	color9                  #ff6e6e   
	cursor                  #f8f8f2   
	foreground              #f8f8f2   
	inactive_tab_background #6272a4   
	inactive_tab_foreground #282a36   
	mark1_background        #ff5555   
	mark1_foreground        #282a36   
	selection_background    #44475a   
	selection_foreground    #ffffff   
	url_color               #8be9fd   

Important environment variables seen by the kitty process:
	PATH                                /home/username/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/username/bin
	LANG                                en_US.UTF-8
	EDITOR                              nvim
	SHELL                               /bin/bash
	DISPLAY                             :1
	WAYLAND_DISPLAY                     wayland-0
	USER                                username
	XCURSOR_SIZE                        24
	XDG_CONFIG_DIRS                     /home/username/.config/kdedefaults:/etc/xdg
	XDG_CURRENT_DESKTOP                 KDE
	XDG_DATA_DIRS                       /home/username/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
	XDG_RUNTIME_DIR                     /run/user/1000
	XDG_SEAT                            seat0
	XDG_SEAT_PATH                       /org/freedesktop/DisplayManager/Seat0
	XDG_SESSION_CLASS                   user
	XDG_SESSION_DESKTOP                 KDE
	XDG_SESSION_ID                      8
	XDG_SESSION_PATH                    /org/freedesktop/DisplayManager/Session6
	XDG_SESSION_TYPE                    wayland
	XDG_VTNR                            2

Additional context
The issue persists with kitty config=NONE. I also tried using the kitty-git AUR package to see if this was fixed in a development version, and I saw the same behavior. Note that the revision on the AUR page isn't accurate - that's just bumped manually by the maintainer periodically so people using AUR helper scripts can detect an update. The actually revisions for kitty/related packages were:

local/kitty-git 1:r10605.g03fe928e-1
    Modern, hackable, featureful, OpenGL based terminal emulator
local/kitty-shell-integration-git 1:r10605.g03fe928e-1
    Shell integration scripts for kitty, an OpenGL-based terminal emulator
local/kitty-terminfo-git 1:r10605.g03fe928e-1
    Terminfo for kitty, an OpenGL-based terminal emulator

I've attached the latest coredump if that's helpful.
kitty.dump.gz

Edit: an update to kitty version 0.26.4 was made available on the Arch repos very shortly after I submitted this report, and the issue still persists in that version.

@saucyfox saucyfox added the bug label Oct 18, 2022
@kovidgoyal
Copy link
Owner

Does not segfault for me with up-to-date kitty (0.26.4) I suggest you
update. And if it is still reproducable, then post a backtrace.

@saucyfox
Copy link
Author

I did update to the latest version (which was made available in the arch repos shortly after I had posted this) and edited my initial report to note that. It's at the end of the note though so probably easy to miss - sorry about that.

Here's a backtrace:

Thread 1 "kitty" received signal SIGABRT, Aborted.
__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  0x00007ffff7a746b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff7a24958 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7a0e53d in __GI_abort () at abort.c:79
#4  0x00007ffff5f2c4f2 in wl_abort (fmt=fmt@entry=0x7ffff5f31338 "listener function for opcode %u of %s is NULL\n") at ../wayland-1.21.0/src/wayland-util.c:462
#5  0x00007ffff5f2c700 in wl_closure_invoke (closure=closure@entry=0x555556279b90, target=<optimized out>, target@entry=0x5555562357f0, opcode=opcode@entry=0, data=<optimized out>, flags=1) at ../wayland-1.21.0/src/connection.c:1022
#6  0x00007ffff5f2ce03 in dispatch_event (display=display@entry=0x5555556ef350, queue=0x5555556ef420) at ../wayland-1.21.0/src/wayland-client.c:1595
#7  0x00007ffff5f2cffc in dispatch_queue (queue=0x5555556ef420, display=0x5555556ef350) at ../wayland-1.21.0/src/wayland-client.c:1741
#8  wl_display_dispatch_queue_pending (display=0x5555556ef350, queue=0x5555556ef420) at ../wayland-1.21.0/src/wayland-client.c:1983
#9  0x00007ffff5e1abfe in glfwRunMainLoop () from /usr/lib/kitty/kitty/glfw-wayland.so
#10 0x00007ffff6ceda3c in ?? () from /usr/bin/../lib/kitty/kitty/fast_data_types.so
#11 0x00007ffff7d2b414 in method_vectorcall_NOARGS (func=0x7ffff740e200, args=0x555555836850, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/descrobject.c:432
#12 0x00007ffff7d181ca in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x555555836850, callable=0x7ffff740e200, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#13 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x555555836850, callable=0x7ffff740e200) at ./Include/cpython/abstract.h:123
#14 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffff9e10, tstate=<optimized out>) at Python/ceval.c:5891
#15 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x555555836650, throwflag=<optimized out>) at Python/ceval.c:4198
#16 0x00007ffff7d28b79 in _PyEval_EvalFrame (throwflag=0, f=0x555555836650, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#17 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff6145fd0, tstate=0x555555577790) at Python/ceval.c:5065
#18 _PyFunction_Vectorcall (func=0x7ffff6145fc0, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:342
#19 0x00007ffff7d17d96 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff6145fc0, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#20 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff6145fc0) at ./Include/cpython/abstract.h:123
#21 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffff9fd0, tstate=<optimized out>) at Python/ceval.c:5891
#22 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x7ffff6371970, throwflag=<optimized out>) at Python/ceval.c:4213
#23 0x00007ffff7d210bb in _PyEval_EvalFrame (throwflag=0, f=0x7ffff6371970, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#24 _PyEval_Vector (kwnames=0x0, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff6146180, tstate=0x555555577790) at Python/ceval.c:5065
#25 _PyFunction_Vectorcall (kwnames=0x0, nargsf=<optimized out>, stack=<optimized out>, func=0x7ffff6146170) at Objects/call.c:342
#26 _PyObject_FastCallDictTstate (tstate=0x555555577790, callable=0x7ffff6146170, args=<optimized out>, nargsf=<optimized out>, kwargs=<optimized out>) at Objects/call.c:142
#27 0x00007ffff7d319dd in _PyObject_Call_Prepend (tstate=0x555555577790, callable=0x7ffff6146170, obj=0x7ffff73b1390, args=<optimized out>, kwargs=0x0) at Objects/call.c:431
#28 0x00007ffff7dfd802 in slot_tp_call (self=0x7ffff73b1390, args=0x7ffff6168950, kwds=0x0) at Objects/typeobject.c:7494
#29 0x00007ffff7d21dcb in _PyObject_MakeTpCall (tstate=0x555555577790, callable=0x7ffff73b1390, args=<optimized out>, nargs=4, keywords=0x0) at Objects/call.c:215
#30 0x00007ffff7d1cba4 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=<optimized out>, tstate=<optimized out>) at ./Include/cpython/abstract.h:112
#31 _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=<optimized out>, tstate=<optimized out>) at ./Include/cpython/abstract.h:99
#32 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=<optimized out>) at ./Include/cpython/abstract.h:123
#33 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffa2f0, tstate=<optimized out>) at Python/ceval.c:5891
#34 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:4213
#35 0x00007ffff7d28b79 in _PyEval_EvalFrame (throwflag=0, f=0x555555711070, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#36 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff6146840, tstate=0x555555577790) at Python/ceval.c:5065
#37 _PyFunction_Vectorcall (func=0x7ffff6146830, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:342
#38 0x00007ffff7d17d96 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff6146830, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#39 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff6146830) at ./Include/cpython/abstract.h:123
#40 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffa4b0, tstate=<optimized out>) at Python/ceval.c:5891
#41 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x7ffff75476a0, throwflag=<optimized out>) at Python/ceval.c:4213
#42 0x00007ffff7d28b79 in _PyEval_EvalFrame (throwflag=0, f=0x7ffff75476a0, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#43 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff61468d0, tstate=0x555555577790) at Python/ceval.c:5065
#44 _PyFunction_Vectorcall (func=0x7ffff61468c0, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:342
#45 0x00007ffff7d17d96 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff61468c0, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#46 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff61468c0) at ./Include/cpython/abstract.h:123
#47 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffa670, tstate=<optimized out>) at Python/ceval.c:5891
#48 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x7ffff74d4240, throwflag=<optimized out>) at Python/ceval.c:4213
#49 0x00007ffff7d28b79 in _PyEval_EvalFrame (throwflag=0, f=0x7ffff74d4240, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#50 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff73aacc0, tstate=0x555555577790) at Python/ceval.c:5065
#51 _PyFunction_Vectorcall (func=0x7ffff73aacb0, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:342
#52 0x00007ffff7d17d96 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff73aacb0, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#53 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff73aacb0) at ./Include/cpython/abstract.h:123
#54 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffa830, tstate=<optimized out>) at Python/ceval.c:5891
#55 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x7ffff75a5f80, throwflag=<optimized out>) at Python/ceval.c:4213
#56 0x00007ffff7d169e0 in _PyEval_EvalFrame (throwflag=0, f=0x7ffff75a5f80, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#57 _PyEval_Vector (tstate=0x555555577790, con=0x7fffffffa930, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=<optimized out>) at Python/ceval.c:5065
#58 0x00007ffff7dc5604 in PyEval_EvalCode (co=0x7ffff74e6ef0, globals=0x7ffff7455880, locals=0x7ffff7455880) at Python/ceval.c:1134
#59 0x00007ffff7dcb98b in builtin_exec_impl (module=<optimized out>, locals=0x7ffff7455880, globals=0x7ffff7455880, source=0x7ffff74e6ef0) at Python/bltinmodule.c:1056
#60 builtin_exec (module=<optimized out>, args=<optimized out>, nargs=<optimized out>) at Python/clinic/bltinmodule.c.h:371
#61 0x00007ffff7d28d6f in cfunction_vectorcall_FASTCALL (func=0x7ffff75b0e00, args=0x55555563f968, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:430
#62 0x00007ffff7d17d96 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff75b0e00, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#63 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff75b0e00) at ./Include/cpython/abstract.h:123
#64 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffab00, tstate=<optimized out>) at Python/ceval.c:5891
#65 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x55555563f7b0, throwflag=<optimized out>) at Python/ceval.c:4213
#66 0x00007ffff7d28b79 in _PyEval_EvalFrame (throwflag=0, f=0x55555563f7b0, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#67 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff7338200, tstate=0x555555577790) at Python/ceval.c:5065
#68 _PyFunction_Vectorcall (func=0x7ffff73381f0, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:342
#69 0x00007ffff7d17d96 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff73381f0, tstate=0x555555577790) at ./Include/cpython/abstract.h:114
#70 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, callable=0x7ffff73381f0) at ./Include/cpython/abstract.h:123
#71 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffacc0, tstate=<optimized out>) at Python/ceval.c:5891
#72 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=0x7ffff7541840, throwflag=<optimized out>) at Python/ceval.c:4213
#73 0x00007ffff7d28b79 in _PyEval_EvalFrame (throwflag=0, f=0x7ffff7541840, tstate=0x555555577790) at ./Include/internal/pycore_ceval.h:46
#74 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff7338710, tstate=0x555555577790) at Python/ceval.c:5065
#75 _PyFunction_Vectorcall (func=0x7ffff7338700, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:342
#76 0x00007ffff7de9707 in pymain_run_module (modname=<optimized out>, set_argv0=<optimized out>) at Modules/main.c:293
#77 0x00007ffff7c68b35 in pymain_run_python (exitcode=0x7fffffffae24) at Modules/main.c:584
#78 Py_RunMain () at Modules/main.c:666
#79 0x0000555555556567 in main ()

Additionally, when I run kitty --debug-input, I see the error listener function for opcode 0 of wl_data_source is NULL right after pasting in firefox; which I don't see when pasting in Kate. I also tried kitty --dump-commands; which didn't show any errors other than the one I just mentioned.

@kovidgoyal
Copy link
Owner

That's an abort in libwayland not a crash, run kitty from another
terminal, there should be some information printed there. Also I cannot
reproduce with the following steps under KDE wayland

  1. Start kitty
  2. Run ls and copy some text
  3. STart firefox
  4. Paste into the address bar

Wrks as expected

@saucyfox
Copy link
Author

I should have mentioned - firefox runs with xwayland by default. You have to set MOZ_ENABLE_WAYLAND=1 in your environment to force it to use Wayland natively. I think some distros do that by default now, but as is typical for Arch it's the user's responsibility in this case. When I unset that variable and run firefox, I'm not able to reproduce it either.

Here's a short recording of the behavior: https://www.youtube.com/watch?v=ih7uhOV3DaE

@kovidgoyal
Copy link
Owner

seems to be KDE specific. Doesn't abort under sway or gnome. So report it
to kwin. The error from libwayland is listener function for opcode 0 of wl_data_source
is NULL I have no idea what that means. kitty always adds listeners for
data sources, indeed if it didn't copy/paste would not work at all. It
could be complaining about some of the fields in the wl_data_source
struct being null, which is silly, since the NULL fields are used for
drag and drop not copy paste and this is a copy/paste source.

@python-wizard
Copy link

I have exactly the same issue on Fedora 36 KDE Plasma 5.25.5 on Wayland with Nvidia drivers 520.56.06-1.
It appeared just after updating to Kernel 6.0.5 from Kernel 5.19 - but before restart, not sure whether the update impacted the system before restart on Fedora.
But I also don't copy from Kitty to Firefox every day. But it has to be reasonably recent.

I can post more info if you tell me what command to run.

Also, just confirmed, when I copy to Kwrite, there is no problem, only copying to Firefox causes a problem.
MOZ_ENABLE_WAYLAND is set to 1 in about:support.

@kovidgoyal
Copy link
Owner

this is already fixed in master, see the commit that closed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants