Bug 408603 - Konsole crash when coping highlighted text
Summary: Konsole crash when coping highlighted text
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: copy-paste (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: David Hallas
URL:
Keywords:
: 414748 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-06-12 08:57 UTC by J.Novo
Modified: 2021-05-01 18:30 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 19.08.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J.Novo 2019-06-12 08:57:19 UTC
SUMMARY
In konsole crash when you do a search and try to copy text containing highlighted text.

STEPS TO REPRODUCE
1. Open konsole and try to find something (edit - find)
2. Select text containing a hightlighted match with mouse and right click and copy.

OBSERVED RESULT
Konsole crash.


SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.16
KDE Plasma Version: 5.16.0
KDE Frameworks Version: 5.59.0
Qt Version: 5.12.3
Kernel Version: 4.15.0-51-generic
OS Type: 64-bit

ADDITIONAL INFORMATION

Application: Konsole (konsole), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f90ee603800 (LWP 18452))]

Thread 3 (Thread 0x7f90c8e63700 (LWP 18456)):
#0  0x00007f90e54969f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x560c2fcbba88) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x560c2fcbba38, cond=0x560c2fcbba60) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x560c2fcbba60, mutex=0x560c2fcbba38) at pthread_cond_wait.c:655
#3  0x00007f90c9fe8dcb in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#4  0x00007f90c9fe8af7 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#5  0x00007f90e54906db in start_thread (arg=0x7f90c8e63700) at pthread_create.c:463
#6  0x00007f90edf2688f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f90d17ce700 (LWP 18455)):
#0  0x00007f90edf150b4 in __GI___libc_read (fd=7, buf=0x7f90d17cdb60, nbytes=16) at ../sysdeps/unix/sysv/linux/read.c:27
#1  0x00007f90e378f000 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f90e3749fb7 in g_main_context_check () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f90e374a470 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007f90e374a5dc in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f90ea3b0dcb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f90ea35203a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f90ea1794ca in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f90e7bab015 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#9  0x00007f90ea17ac72 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007f90e54906db in start_thread (arg=0x7f90d17ce700) at pthread_create.c:463
#11 0x00007f90edf2688f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f90ee603800 (LWP 18452)):
[KCrash Handler]
#6  0x00007f90eb15b3a3 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#7  0x00007f90eb186b86 in QWidget::removeAction(QAction*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#8  0x00007f90edb735d1 in Konsole::SessionController::showDisplayContextMenu(QPoint const&) () from /usr/lib/x86_64-linux-gnu/libkonsoleprivate.so.19
#9  0x00007f90ea38398f in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007f90edbb0195 in Konsole::TerminalDisplay::configureRequest(QPoint const&) () from /usr/lib/x86_64-linux-gnu/libkonsoleprivate.so.19
#11 0x00007f90edb90532 in Konsole::TerminalDisplay::mousePressEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libkonsoleprivate.so.19
#12 0x00007f90eb19031f in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007f90eb14f65c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007f90eb157a58 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007f90ea353d18 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007f90eb15605f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007f90eb1aa8a1 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007f90eb1ad6fa in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007f90eb14f65c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007f90eb156b90 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007f90ea353d18 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007f90ea91d1fb in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#23 0x00007f90ea91e365 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#24 0x00007f90ea8f6b4b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#25 0x00007f90dbeff59a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#26 0x00007f90e374a317 in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x00007f90e374a550 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007f90e374a5dc in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007f90ea3b0dcb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x00007f90ea35203a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007f90ea35b170 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007f90ee21dcdd in kdemain () from /usr/lib/x86_64-linux-gnu/libkdeinit5_konsole.so
#33 0x00007f90ede26b97 in __libc_start_main (main=0x560c2db8d720, argc=1, argv=0x7ffd960fc108, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd960fc0f8) at ../csu/libc-start.c:310
#34 0x0000560c2db8d75a in _start ()
Comment 1 Kurt Hindenburg 2019-06-12 14:40:10 UTC
What version of Konsole are you using?  A lot has changed recently and I can't reproduce on 19.04 nor master.
Comment 2 J.Novo 2019-06-12 15:55:42 UTC
Version 19.04.2
KDE Frameworks 5.59.0
Qt 5.12.3 (built against 5.12.3)

I tried again and seems that is only happening with links like file:// or http://.

I can reproduce it like:

1. echo https://kde.org/
2. edit->find
3. type kde in the search box
4. select kde.org
5. right click and click copy
Comment 3 Kurt Hindenburg 2019-06-15 15:21:17 UTC
Thanks for the steps to follow - it crashes on 19.04 but not current master (19.08)

I'll research
Comment 4 Kurt Hindenburg 2019-06-15 16:26:38 UTC
git bisect says 7265be97a2e9d84c4e036d426ffb0085710d9361 caused this.

https://phabricator.kde.org/D19636

Strange, master doesn't show this issue.
Comment 5 Kurt Hindenburg 2019-06-15 16:39:11 UTC
It happens on master as well
Comment 6 David Hallas 2019-06-16 15:33:33 UTC
I have pushed a review that fixes this crash:

https://phabricator.kde.org/D21849

I have tested quite a bit with this patch and haven't seen any crashes or leaks, but please give it a thorough test as well, just to be sure. I don't want to introduce any other regressions :D

And thanks for reporting the issue!
Comment 7 Kurt Hindenburg 2019-06-16 15:53:57 UTC
Thanks, so far it looks good.  

I'm not clear on why when searching the links are no longer valid (no open/copy url, email, etc) even when the links are not highlighted.  Although not really related to this crash or fix.
Comment 8 David Hallas 2019-06-16 15:55:29 UTC
(In reply to Kurt Hindenburg from comment #7)
> Thanks, so far it looks good.  
> 
> I'm not clear on why when searching the links are no longer valid (no
> open/copy url, email, etc) even when the links are not highlighted. 
> Although not really related to this crash or fix.

Me neither :/

I think in general there are a bit too many raw pointers in this code for my taste :) It would be nice to work towards changing them to more safer alternatives.
Comment 9 J.Novo 2019-06-16 16:44:41 UTC
(In reply to David Hallas from comment #6)
> I have pushed a review that fixes this crash:
> 
> https://phabricator.kde.org/D21849
> 
> I have tested quite a bit with this patch and haven't seen any crashes or
> leaks, but please give it a thorough test as well, just to be sure. I don't
> want to introduce any other regressions :D
> 
> And thanks for reporting the issue!

Works good here.

Btw, i noticed the search box is not correctly aligned.

When i first open it it is positioned like in the middle, then if you resize the window it changes position to like the top right.

Thanks!
Comment 10 Kurt Hindenburg 2019-06-17 00:46:46 UTC
Git commit 2562c3a003f6359fe2b5afae9ab5b1c318bf35ad by Kurt Hindenburg, on behalf of David Hallas.
Committed on 16/06/2019 at 15:35.
Pushed by scmsync into branch 'master'.

Fixes crash when copying hotspot

Summary:
Fixes crash when copying hotspot. It is caused by the code would remove
any actions from the hotspot after the context menu had executed, but
these actions have now been freed because the hotspot is freed (this was
done in 7265be97a2e9d84c4e036d426ffb0085710d9361 to fix a memory leak).

Test Plan:
echo https://kde.org/
edit->find
type kde in the search box
select kde.org
right click and click copy

Reviewers: #konsole, hindenburg

Subscribers: konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D21849

M  +0    -9    src/SessionController.cpp

https://commits.kde.org/konsole/2562c3a003f6359fe2b5afae9ab5b1c318bf35ad
Comment 11 Kurt Hindenburg 2019-06-17 00:46:46 UTC
Git commit 2562c3a003f6359fe2b5afae9ab5b1c318bf35ad by Kurt Hindenburg, on behalf of David Hallas.
Committed on 16/06/2019 at 15:35.
Pushed by hindenburg into branch 'master'.

Fixes crash when copying hotspot

Summary:
Fixes crash when copying hotspot. It is caused by the code would remove
any actions from the hotspot after the context menu had executed, but
these actions have now been freed because the hotspot is freed (this was
done in 7265be97a2e9d84c4e036d426ffb0085710d9361 to fix a memory leak).

Test Plan:
echo https://kde.org/
edit->find
type kde in the search box
select kde.org
right click and click copy

Reviewers: #konsole, hindenburg

Subscribers: konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D21849

M  +0    -9    src/SessionController.cpp

https://invent.kde.org/kde/konsole/commit/2562c3a003f6359fe2b5afae9ab5b1c318bf35ad
Comment 12 Yan 2019-09-17 15:15:16 UTC
High! This issue is hitting me daily, most probably it's dupe of https://bugs.kde.org/show_bug.cgi?id=411183

I am using kubuntu backports ppa, will the fix be released for 19.04? Or how can I get fixed konsole?
Comment 13 ninjalj 2021-05-01 18:30:40 UTC
*** Bug 414748 has been marked as a duplicate of this bug. ***