Bug 479315

Summary: kwin_wayland crashes in overview effect when using bookmarks in search with multiple screens
Product: [Plasma] krunner Reporter: fanzhuyifan
Component: bookmarksAssignee: fanzhuyifan
Status: RESOLVED FIXED    
Severity: crash CC: alexander.lohnau, natalie_clarius
Priority: NOR Keywords: qt6
Version First Reported In: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=478998
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description fanzhuyifan 2024-01-02 20:39:38 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. In system settings, only enable bookmarks in plasma search
2. enable overview effect
3. type "bookmarks" in search field

steps 2-3 may need to be repeated a couple of times to trigger the crash.

OBSERVED RESULT
kwin_wayland crashes

EXPECTED RESULT
kwin_wayland does not crash

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.91.90
KDE Frameworks Version: 5.248.0
Qt Version: 6.7.0
Kernel Version: 6.6.8-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 13th Gen Intel® Core™ i9-13900H
Memory: 15.2 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ROG Zephyrus G16 GU603VV_GU603VV
System Version: 1.0

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2024-01-02 20:53:55 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3740
Comment 2 fanzhuyifan 2024-01-02 21:28:29 UTC
This bug only seems to happen with multiple screens.
Comment 3 Bug Janitor Service 2024-01-03 16:59:32 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3742
Comment 4 fanzhuyifan 2024-01-03 18:03:34 UTC
Git commit cccfc652bd4200bc4944a616ca21eb4d308112b1 by Yifan Zhu.
Committed on 03/01/2024 at 18:45.
Pushed by fanzhuyifan into branch 'master'.

runners/bookmarks: re-add per thread db connection

Partially reverts commit 59983ac0dcf77362adfe5b4b2df298c3f53467e9.
Create new connection for each thread, instead of sharing one connection.

When using the search field in the overview effect with multiple
monitors, there are multiple instances of the same runner in the same
process. Previously, these different instances used the same db
connection from different threads, causing the crash in BUG 479315.
According to Qt documentation, "A connection can only be used from
within the thread that created it. Moving connections between threads or
creating queries from a different thread is not supported."
(https://doc.qt.io/qt-6/threads-modules.html#threads-and-the-sql-module)

M  +12   -4    runners/bookmarks/fetchsqlite.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/cccfc652bd4200bc4944a616ca21eb4d308112b1