Bug 483631 - Legacy VI-Mode config crashes kate and kwrite
Summary: Legacy VI-Mode config crashes kate and kwrite
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 24.02.0
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-03-15 08:20 UTC by Andreas
Modified: 2024-03-15 17:28 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas 2024-03-15 08:20:43 UTC
SUMMARY

Kate and kwrite fail to digest certain legacy configuration and crash during startup.

STEPS TO REPRODUCE
1.  Insert specific config in your $HOME/.config/katevirc :

[Kate Vi Input Mode Settings]
Command Mode Mapping Keys=
Command Mode Mappings=
Command Mode Mappings Recursion=
Insert Mode Mapping Keys=
Insert Mode Mappings=
Insert Mode Mappings Recursion=
Macro Completions=
Macro Contents=
Macro Registers=
Map Leader=,
Normal Mode Mapping Keys=<c-v>,<s-insert>,v<left>w
Normal Mode Mappings="+gP,"+gP,vb
Normal Mode Mappings Recursion=false,false,false
ViRegisterContents=inconclusive,\t\t\t\t\t<p>\n\t\t\t\t\t\tIn contrast to previous evaluation\\, the evaluator determined that <b>no</b> additional packages that be acquired this time. The distribution DVDs are in fact self-contained. \n\t\t\t\t\t\t<!--are clearly identified in the <bibref>ECG</bibref> and a URL is given so that the administrator can find the additional packages on the SUSE FTP site. Sufficient instructions are given so that the administrator can reasonably be expected to find and download the correct additional packages. The evaluator found also that sufficient instructions are given so that the administrator can check the integrity of the downloaded packages using the instructions given.-->\n\t\t\t\t\t</p>\n,<dl>\n                     The extended components definition in ASE_ECD.\n                  </dl>\n                  <dt>\n                  </dt>\n                  <dl>\n                     The remaining\\, non-mandatory parts of the ST.\n                  </dl>\n                  <dt>\n                  </dt>\n               </ul>
ViRegisterFlags=0,1,0
ViRegisterNames=-,0,^
Visual Mode Mapping Keys=<s-c-a-m-><s->,<c-x>,<c-c>,<c-insert>
Visual Mode Mappings="+y,"+x,"+x,"+y
Visual Mode Mappings Recursion=false,false,false,false

2.  Run kate or kwrite
3.  Observe the crash

OBSERVED RESULT

The application crashes during startup.

Output of "strace kwrite" is:

readlink("/home", 0x7ffc14ffd8f0, 1023) = -1 EINVAL (Invalid argument)
readlink("~", 0x7ffc14ffd8f0, 1023) = -1 EINVAL (Invalid argument)
readlink("~/.config", 0x7ffc14ffd8f0, 1023) = -1 EINVAL (Invalid argument)
readlink("~/.config/katevirc", 0x7ffc14ffd8f0, 1023) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, "/home/andreas/.config/katevirc", O_RDONLY|O_CLOEXEC) = 19
statx(19, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=1666, ...}) = 0
statx(19, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=1666, ...}) = 0
statx(19, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=1666, ...}) = 0
read(19, "[Kate Vi Input Mode Settings]\nCo"..., 16384) = 1666
read(19, "", 14718)                     = 0
close(19)                               = 0
openat(AT_FDCWD, "/dev/tty", O_RDONLY|O_CLOEXEC) = 19
close(19)                               = 0
write(2, "ASSERT: \"rc <= 0xffff\" in file /"..., 89ASSERT: "rc <= 0xffff" in file /usr/include/x86_64-linux-gnu/qt6/QtCore/qchar.h, line 79
) = 89
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
gettid()                                = 680280
getpid()                                = 680280
tgkill(680280, 680280, SIGABRT)         = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=680280, si_uid=1001} ---
+++ killed by SIGABRT +++
Aborted

I do not get offered a debug option, therefore, no complete debug logs included.

EXPECTED RESULT

Kwrite and kate handle the apparently invalid config gracefully and startup normally.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon user edition
KDE Plasma Version: 6.0.2
KDE Frameworks Version: Version 6.0.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION

I upgraded from KDE Neon user edition where the config used to work.
It suffices to remove the line 
Visual Mode Mapping Keys=<s-c-a-m-><s->,<c-x>,<c-c>,<c-insert>
from above config.
Comment 1 Waqar Ahmed 2024-03-15 08:22:39 UTC
do you have a backtrace?
Comment 2 Andreas 2024-03-15 09:09:57 UTC
As mentioned I do unfortunately not have a backtrace. How could I enforce its creation without compiling from sources?
Comment 3 Andreas 2024-03-15 13:22:49 UTC
Would that suffice (does not seem to provide a lot more info)?

~> gdb kwrite
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 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 kwrite...
Reading symbols from /usr/lib/debug/.build-id/da/b5cd68711f7c03f634e7e3f0e426cf8808d3cb.debug...
(gdb) run
Starting program: /usr/bin/kwrite 

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.neon.kde.org/:
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff03ff640 (LWP 3265322)]
[New Thread 0x7fffeef5d640 (LWP 3265323)]
[New Thread 0x7fffee75c640 (LWP 3265324)]
[New Thread 0x7fffed952640 (LWP 3265543)]
[New Thread 0x7fffed151640 (LWP 3265750)]
[New Thread 0x7fffec950640 (LWP 3265751)]
[New Thread 0x7fffd6dff640 (LWP 3265752)]
[New Thread 0x7fffd65fe640 (LWP 3265753)]
[New Thread 0x7fffd5dfd640 (LWP 3265754)]
[New Thread 0x7fffd55fc640 (LWP 3265755)]
[New Thread 0x7fffd4dfb640 (LWP 3265756)]
[New Thread 0x7fffb7fff640 (LWP 3265757)]
[New Thread 0x7fffb77fe640 (LWP 3265758)]
[New Thread 0x7fffb6ffd640 (LWP 3265759)]
[Thread 0x7fffb6ffd640 (LWP 3265759) exited]
[Thread 0x7fffb77fe640 (LWP 3265758) exited]
[Thread 0x7fffb7fff640 (LWP 3265757) exited]
[Thread 0x7fffd4dfb640 (LWP 3265756) exited]
ASSERT: "rc <= 0xffff" in file /usr/include/x86_64-linux-gnu/qt6/QtCore/qchar.h, line 79

Thread 1 "kwrite" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737228689344) at ./nptl/pthread_kill.c:44
Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
44      ./nptl/pthread_kill.c: No such file or directory.
Comment 4 Christoph Cullmann 2024-03-15 16:30:20 UTC
That is helpful, I will take a look!
Comment 5 Christoph Cullmann 2024-03-15 17:28:20 UTC
Git commit d005ab8c9f14e6fb7923b46c7b8c36ed97e1c9f2 by Christoph Cullmann.
Committed on 15/03/2024 at 17:28.
Pushed by cullmann into branch 'master'.

avoid using QChar constructor for key codes

auto c7 = QChar(0x1D11E);           // compiles, but undefined behavior at runtime

M  +2    -2    src/vimode/keyparser.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/d005ab8c9f14e6fb7923b46c7b8c36ed97e1c9f2
Comment 6 Christoph Cullmann 2024-03-15 17:28:54 UTC
I hope that are the right locations, I understand the error but are not able to reproduce.