Bug 258996 - x11/konsole typing exit or ctrl-D from shell causes konsole to crash claiming program running
Summary: x11/konsole typing exit or ctrl-D from shell causes konsole to crash claiming...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-kde (group)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-08 01:27 UTC by alt2600
Modified: 2021-10-18 22:06 UTC (History)
3 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments
konsole end file kernel running.jpg (91.32 KB, image/jpeg)
2021-10-12 01:06 UTC, alt2600
no flags Details
clean lldb, console messages, env output (3.47 KB, text/plain)
2021-10-12 01:08 UTC, alt2600
no flags Details
Screenshot of helloSystem (98.88 KB, image/png)
2021-10-17 05:11 UTC, Graham Perrin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description alt2600 2021-10-08 01:27:10 UTC
konsole no longer allows a close file, exit nor ctrl-D, from shell without claiming there is a running process. if you click cancel instead of ignore konsole crashes. the running process is indicated to be "kernel" . all KDE components upgraded to new versions from console shell, not under X11.

output from KDE crash handler

Executable module set to "/usr/local/bin/konsole".
Architecture set to: x86_64--freebsd12.2.
(lldb) settings set term-width 200
(lldb) thread info
thread #1: tid = 101079, 0x0000000802ac8c68 libc.so.7`__sys_wait4 at _wait4.S:3, name = 'konsole'

(lldb) bt all
* thread #1, name = 'konsole'
  * frame #0: 0x0000000802ac8c68 libc.so.7`__sys_wait4 at _wait4.S:3
    frame #1: 0x0000000803a04e5c libthr.so.3`__thr_wait4(pid=<unavailable>, status=<unavailable>, options=<unavailable>, rusage=<unavailable>) at thr_syscalls.c:581:8
    frame #2: 0x000000080138a6db libKF5Crash.so.5`___lldb_unnamed_symbol5$$libKF5Crash.so.5 + 315
    frame #3: 0x0000000801389e2a libKF5Crash.so.5`KCrash::defaultCrashHandler(int) + 1498
    frame #4: 0x0000000803a07ae0 libthr.so.3`handle_signal(actp=0x00007fffffffd740, sig=11, info=0x00007fffffffdb30, ucp=0x00007fffffffd7c0) at thr_sig.c:248:3
    frame #5: 0x0000000803a070ac libthr.so.3`thr_sighandler(sig=11, info=0x00007fffffffdb30, _ucp=0x00007fffffffd7c0) at thr_sig.c:191:2
    frame #6: 0x00007ffffffff193
    frame #7: 0x000000080287aca9 libQt5Core.so.5`QTimer::start() + 25
    frame #8: 0x000000080287592e libQt5Core.so.5`___lldb_unnamed_symbol2429$$libQt5Core.so.5 + 1150
    frame #9: 0x000000080038c930 libkonsoleprivate.so.21`Konsole::TerminalDisplay::compositeFocusChanged(bool) + 64
    frame #10: 0x000000080287592e libQt5Core.so.5`___lldb_unnamed_symbol2429$$libQt5Core.so.5 + 1150
    frame #11: 0x000000080038d01d libkonsoleprivate.so.21`___lldb_unnamed_symbol367$$libkonsoleprivate.so.21 + 61
    frame #12: 0x00000008003f0846 libkonsoleprivate.so.21`___lldb_unnamed_symbol1267$$libkonsoleprivate.so.21 + 150
    frame #13: 0x000000080283e6a8 libQt5Core.so.5`QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 264
    frame #14: 0x000000080169ba6b libQt5Widgets.so.5`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    frame #15: 0x000000080169cf66 libQt5Widgets.so.5`QApplication::notify(QObject*, QEvent*) + 518
    frame #16: 0x000000080283e34f libQt5Core.so.5`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 175
    frame #17: 0x0000000801699387 libQt5Widgets.so.5`QApplicationPrivate::setFocusWidget(QWidget*, Qt::FocusReason) + 391
    frame #18: 0x00000008016d18e2 libQt5Widgets.so.5`QWidget::setFocus(Qt::FocusReason) + 658
    frame #19: 0x000000080169a889 libQt5Widgets.so.5`QApplication::setActiveWindow(QWidget*) + 1225
    frame #20: 0x000000080169ad56 libQt5Widgets.so.5`QApplicationPrivate::notifyActiveWindowChange(QWindow*) + 54
    frame #21: 0x0000000801e02c13 libQt5Gui.so.5`QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent*) + 627
    frame #22: 0x0000000801de3adb libQt5Gui.so.5`QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 219
    frame #23: 0x000000080701689f libQt5XcbQpa.so.5`___lldb_unnamed_symbol349$$libQt5XcbQpa.so.5 + 31
    frame #24: 0x00000008046fbccc libglib-2.0.so.0`g_main_context_dispatch + 364
    frame #25: 0x00000008046fc064 libglib-2.0.so.0`___lldb_unnamed_symbol129$$libglib-2.0.so.0 + 548
    frame #26: 0x00000008046fc126 libglib-2.0.so.0`g_main_context_iteration + 102
    frame #27: 0x0000000802896d70 libQt5Core.so.5`QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 96
    frame #28: 0x000000080283a627 libQt5Core.so.5`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 567
    frame #29: 0x000000080283e9de libQt5Core.so.5`QCoreApplication::exec() + 142
    frame #30: 0x00000000002063da konsole`___lldb_unnamed_symbol5$$konsole + 3242
    frame #31: 0x000000000020550f konsole`___lldb_unnamed_symbol1$$konsole + 255
  thread #2, name = 'konsole'
    frame #0: 0x0000000802adb02a libc.so.7`__sys_poll at _poll.S:3
    frame #1: 0x0000000803a049f6 libthr.so.3`__thr_poll(fds=<unavailable>, nfds=<unavailable>, timeout=<unavailable>) at thr_syscalls.c:338:8
    frame #2: 0x00000008046fc001 libglib-2.0.so.0`___lldb_unnamed_symbol129$$libglib-2.0.so.0 + 449
    frame #3: 0x00000008046fc126 libglib-2.0.so.0`g_main_context_iteration + 102
    frame #4: 0x0000000802896d8b libQt5Core.so.5`QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 123
    frame #5: 0x000000080283a627 libQt5Core.so.5`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 567
    frame #6: 0x000000080266e880 libQt5Core.so.5`QThread::exec() + 160
    frame #7: 0x0000000801325653 libQt5DBus.so.5`___lldb_unnamed_symbol12$$libQt5DBus.so.5 + 19
    frame #8: 0x000000080266f951 libQt5Core.so.5`___lldb_unnamed_symbol214$$libQt5Core.so.5 + 241
    frame #9: 0x0000000803a01faa libthr.so.3`thread_start(curthread=0x0000000804d6b700) at thr_create.c:292:16
Comment 1 Tobias C. Berner freebsd_committer freebsd_triage 2021-10-08 07:00:26 UTC
Moin moin 

I cannot reproduce this locally. 

* What version of konsole are you using exactly?
* What's the shell you're using?
* Anything special configured in konsole? (i.e. have you tried the default profile)


mfg Tobias
Comment 2 alt2600 2021-10-08 20:16:34 UTC
(In reply to Tobias C. Berner from comment #1)

12.2-RELEASE-p10 FreeBSD

Version 21.08.2
/bin/sh
nothing fancy in my profile, happens with default, brand new, and existing profile.

tried rebooting and rebuilding konsole, no change.

only kde related hacks are qmake fixes to allow qt-3d to build correctly for < haswell arch.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248155
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255753

for completeness sake:
also running openmpi --without-ofi
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256037

and py-scipy WITH_ATLAS
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257400
Comment 3 Adriaan de Groot freebsd_committer freebsd_triage 2021-10-11 14:13:58 UTC
Can't reproduce it either -- this **could** be a 12-specific thing, or because konsole has one million options, any one of them. Please attach a screenshot of your konsole before the crash, and one of the during-the-crash state (it complains about the shell not exiting?)

What environment are you running this in?

The backtrace looks valid. The code around the backtrace doesn't look silly either -- but it should not be complaining about a running process, anyway.
Comment 4 alt2600 2021-10-12 01:06:58 UTC
Created attachment 228604 [details]
konsole end file kernel running.jpg

konsole looks normal so I didn't make a picture, infact during some upgrades last night I found that tabs will close fine via Ctrl-D, its only the final tab. only difference to error message state is "~:sh:- Konsole" is the window title. not sure what you mean by environment, but I'll post another text file with lldb events commented, and what the stdout during a crash to the command line from another window launching konsole, and env output scrubbed/modified to eliminate personal information, session cookies, etc. I'll reply back with the contents of the text file, but it might get mangled in the comment, which is why i'm doing both.
Comment 5 alt2600 2021-10-12 01:08:35 UTC
Created attachment 228605 [details]
clean lldb, console messages, env output

format kept data from reply, env, lldb, console messages
Comment 6 alt2600 2021-10-12 01:23:15 UTC
(In reply to Adriaan de Groot from comment #3)

I've been holding off a 13 upgrade as I was hoping some patches would make it in to the tree so I could re-build my system, but I might just go forward with the patches I need in a custom ports tree local branch and give it a go. I have no sentimental attachment to 12.2, just no time to take the system down for the rebuilds, and some long overdue backups prior to them. If yall are under 13 and have no issues, works for me to try that as its the plan anyway to get there. But if it is a 12.2 issue, and its resolvable, that would be cool too. It looks like there is a nullptr being held potentially for the konsole window itself, so maybe it is attaching tracking to process 0, theoretically the kernel? This is beyond my level of understanding, or if process 0 would even be considered the kernel. If you can give me some guidance on how to pull out that nullptr using lldb to see what the structure is just give me an idea of how to find it

as to my Make.conf outside of setting westmere I have no CFLAGS nor CXXFLAGS set, 
CPUTYPE?=westmere
###### CFLAGS+= -march=${CPUTYPE} -mtune=${CPUTYPE}
###### CXXFLAGS+= ${CFLAGS}
COPTFLAGS+= -O -pipe

obviously I have plenty of tweaks in my ports.conf portconf config, but nothing crazy, and not much for kde, mainly media related, software synths, Atlas BLAS, nvidia related, and such, none of which should affect konsole. As indicated only kde hack is the qmake changes to make qt5-3d build non-AVX to let things like pyside2 build and qgis. a few others to get openmpi and py-scipy as referenced above by pr's

text output of attached clean output file. 

(lldb) target create "/usr/local/bin/konsole"
Current executable set to '/usr/local/bin/konsole' (x86_64).
(lldb) r
################## Close window/Alt-f4 konsole
Process 12905 launching
Process 12905 launched: '/usr/local/bin/konsole' (x86_64)
bt
Process 12905 exited with status = 0 (0x00000000) 
(lldb) r
################## Cancel Close during running program prompt
Process 12913 launching
Process 12913 launched: '/usr/local/bin/konsole' (x86_64)
QObject::disconnect: Unexpected nullptr parameter
QObject::connect(Konsole::Session, Konsole::TerminalDisplay): invalid nullptr parameter
Process 12913 stopped
* thread #1, name = 'konsole', stop reason = signal SIGSEGV: invalid address (fault address: 0x334)
    frame #0: 0x000000080286a2ea libQt5Core.so.5`QObject::killTimer(int) + 42
libQt5Core.so.5`QObject::killTimer:
->  0x80286a2ea <+42>: movq   0x38(%r13), %rax
    0x80286a2ee <+46>: movq   0x38(%rax), %rbx
    0x80286a2f2 <+50>: callq  0x80266e630               ; QThread::currentThread()
    0x80286a2f7 <+55>: cmpq   %rbx, %rax
(lldb) r
There is a running process, kill it and restart?: [Y/n] y
################## Close Window during running program prompt
Process 12913 exited with status = -1 (0xffffffff) 
Process 12940 launching
Process 12940 launched: '/usr/local/bin/konsole' (x86_64)
kf.notifications: Playing audio notification failed: Destroyed
Process 12940 exited with status = 0 (0x00000000) 
(lldb) ^D


################## from a command line lanching and hitting Cancel 
################## close window during running program prompty
QObject::disconnect: Unexpected nullptr parameter
QObject::connect(Konsole::Session, Konsole::TerminalDisplay): invalid nullptr parameter
KCrash: crashing... crashRecursionCounter = 2
KCrash: Application Name = konsole path = /usr/local/bin pid = 95012
KCrash: Arguments: /usr/local/bin/konsole 
QSocketNotifier: Invalid socket 11 and type 'Read', disabling...
QSocketNotifier: Invalid socket 12 and type 'Read', disabling...
KCrash: Attempting to start /usr/local/lib/libexec/drkonqi
[1] + Suspended (signal)      konsole


################## Environment, stripped/modified personal information
XCURSOR_PATH=/usr/local/share/icons::~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons
KDE_SESSION_VERSION=5
LOGNAME=userdude
PAGER=less
LANG=en_US.UTF-8
KDE_APPLICATIONS_AS_SCOPE=1
COLORFGBG=15;0
XAUTHORITY=/home/userdude/.Xauthority
KONSOLE_DBUS_WINDOW=/Windows/1
MAIL=/var/mail/userdude
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/userdude/bin
XDG_RUNTIME_DIR=/var/run/user/1001
EDITOR=ee
ENV=/home/userdude/.shrc
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/userdude/.gtkrc-2.0:/home/userdude/.config/gtkrc-2.0
SESSION_MANAGER=local/hostname.faked.com:/tmp/.ICE-unix/9999
KDE_SESSION_UID=1001
GTK_RC_FILES=/etc/gtk/gtkrc:/home/userdude/.gtkrc:/home/userdude/.config/gtkrc
DISPLAY=:0
PROFILEHOME=
PWD=/home/userdude
XDG_CURRENT_DESKTOP=KDE
TERM=xterm-256color
XCURSOR_THEME=Oxygen_Blue
KONSOLE_DBUS_SESSION=/Sessions/1
USER=userdude
QT_AUTO_SCREEN_SCALE_FACTOR=0
HOME=/home/userdude
LC_COLLATE=C
XCURSOR_SIZE=24
WINDOWPATH=9
PS1=|\h@\w|$} 
SHELL=/bin/sh
LANGUAGE=
COLORTERM=truecolor
MM_CHARSET=UTF-8
WINDOWID=102760455
TIGCC=/usr/local/tigcc
KDE_FULL_SESSION=true
XDG_SESSION_COOKIE=hostname.faked.com-9999999999.111111-2222222222
XDG_CONFIG_DIRS=/home/userdude/.config/kdedefaults:/usr/local/etc/xdg:/etc/xdg:/usr/local/etc/xdg
KONSOLE_DBUS_SERVICE=:1.305
SHELL_SESSION_ID=aaaaaaaabbbbbbbbbbbbcccccccccccdd
BLOCKSIZE=K
KONSOLE_VERSION=210802
Comment 7 Adriaan de Groot freebsd_committer freebsd_triage 2021-10-13 12:30:34 UTC
Reported a few more times on Twitter, and I can reproduce in a VM (but not on my main workstation):

- new VM, 12.2 installation, MBR, UFS
- pkg update ; pkg install konsole kde5 xorg-server xorg
- added dbus_enable="YES"
- reboot, log in as "live"
- "startx" (gets me twm), then "konsole" can't reproduce
- Create a .xinitrc to start plasma, can't reproduce.

**BUT** this is wilth konsole 21.08.1 !

- Switched pkg branch from quarterly to latest
- pkg upgrade
- problem exists, both inside plasma and in twm
Comment 8 Adriaan de Groot freebsd_committer freebsd_triage 2021-10-13 12:49:42 UTC
Why I don't see it locally:

security.bsd.see_other_uids=0
security.bsd.see_other_gids=0
security.bsd.see_jail_proc=0

After applying those sysctls to the VM, I cannot reproduce the problem anymore either. Then changing them back to 1, triggers the problem and crash.
Comment 9 alt2600 2021-10-13 21:53:25 UTC
(In reply to Adriaan de Groot from comment #8)

Only under 12.2 or even with 13? I have 1's for all those, presumably the default setting.
Comment 10 alt2600 2021-10-14 00:54:31 UTC
(In reply to Adriaan de Groot from comment #8)

furthermore I can confirm

security.bsd.see_other_uids=0

allows konsole to behave properly on my machine. no error with Ctrl-D

returning it to 
security.bsd.see_other_uids=1

shows the errors again.
Comment 11 Graham Perrin freebsd_committer freebsd_triage 2021-10-17 05:11:28 UTC
Created attachment 228773 [details]
Screenshot of helloSystem

(In reply to alt2600 from comment #2)

> … 12.2-RELEASE-p10 …

Reproducible in a VirtualBox guest with FreeBSD. 

Also reproducible on non-patched 12.2-RELEASE installed by recent 
hello-0.6.0_0F54-FreeBSD-12.2-amd64.iso 
with packages from FreeBSD latest. Screenshot attached. 

Not reproducible on FreeBSD 14.0-CURRENT, 

% pkg info -x konsole
konsole-21.08.2
% freebsd-version -kru
14.0-CURRENT
14.0-CURRENT
14.0-CURRENT
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #112 main-n249988-2c614481fd5: Sun Oct 10 21:42:16 BST 2021     root@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG  amd64 1400036 1400036
%
Comment 12 commit-hook freebsd_committer freebsd_triage 2021-10-18 22:04:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2ca25d7089085af7f8a9201beba4d10ff4cdf1da

commit 2ca25d7089085af7f8a9201beba4d10ff4cdf1da
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2021-10-18 21:52:49 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2021-10-18 21:52:49 +0000

    x11/konsole: avoid weird message when exiting last shell

    Konsole complains about "kernel" still running in the terminal
    when exiting the last shell in the last tab; this only shows
    up if PID 0 is visible (depends on hardening options).
    Avoid that (on Linux, apparently the invalid PID equals the
    invalid foreground group ID).

    PR:             258996
    Reported by:    alt2600@icloud.com

 x11/konsole/Makefile                             |  1 +
 x11/konsole/files/patch-src_MainWindow.cpp (new) | 25 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
Comment 13 Adriaan de Groot freebsd_committer freebsd_triage 2021-10-18 22:06:06 UTC
Thanks all for checking / testing. A fix has been submitted upstream, but I'm landing it in ports here, now. Thanks to Vladimir Mišev on Twitter for suggesting a workaround, which mutated into the patch.