Bug 403970

Summary: Partition manager crashes just by browsing menus
Product: [Applications] partitionmanager Reporter: Lucia Mrenica <lucia.mrenica>
Component: generalAssignee: Andrius Štikonas <andrius>
Status: RESOLVED UPSTREAM    
Severity: normal CC: bugseforuns, johan.helsing, lucia.mrenica
Priority: NOR    
Version First Reported In: Git   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=403966
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Lucia Mrenica 2019-02-05 19:29:17 UTC
STEPS TO REPRODUCE
1. Start partition manager
2. Open any menu (like 'File') and browse between menus by moving your mouse above the other items in menu (like 'Edit' or 'Device')

OBSERVED RESULT
Sooner or later Partition manager's main window will dissapear (the main proces will continue running)

KDE Plasma Version: 5.14.90
KDE Frameworks Version: 5.54
Qt Version: 5.12.1

ADDITIONAL INFORMATION
Tested on wayland

Log looks like this:

LANG=C partitionmanager
Could not load plugin for core backend  "" :  "The shared library was not found."
Loaded backend plugin:  "pmsfdiskbackendplugin"
Using Wayland-EGL
Using the 'xdg-shell' shell integration
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
"Using backend plugin: pmsfdiskbackendplugin (1)"
"Scanning devices..."
"Device found: Samsung SSD 850 EVO 500GB"
smartctl initialization failed for  "/dev/sda" :  No such file or directory
error during smart output parsing for  "/dev/sda" :  No such file or directory
unknown file system type  ""  on  "/dev/sda2"
"Partition ‘/dev/sda3’ is not properly aligned (last sector: 510274081, modulo: 546)."
"Scan finished."
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: Non-toplevel surfaces can't request window states
qt.qpa.wayland: setGrabPopup called for a surface that was not the topmost popup, positions might be off.
qt.qpa.wayland: Non-toplevel surfaces can't request window states
Comment 1 Lucia Mrenica 2019-02-05 19:35:48 UTC
In addition to this I also wasn't able to start partitionmanager with gdb at all. Log:

LANG=C gdb partitionmanager
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 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-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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 partitionmanager...done.

(gdb) run
Starting program: /usr/bin/partitionmanager 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffeefe3700 (LWP 24755)]
Could not load plugin for core backend  "" :  "The shared library was not found."
Loaded backend plugin:  "pmsfdiskbackendplugin"
Using Wayland-EGL
[New Thread 0x7fffe7fff700 (LWP 24756)]
Using the 'xdg-shell' shell integration
[New Thread 0x7fffe77fe700 (LWP 24757)]

Thread 4 "DBusThread" received signal SIG33, Real-time event 33.
[Switching to Thread 0x7fffe77fe700 (LWP 24757)]
0x00007ffff61e2a3d in _int_malloc () from /usr/lib/libc.so.6

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/bin/partitionmanager 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffeefe3700 (LWP 24767)]
Could not load plugin for core backend  "" :  "The shared library was not found."
Loaded backend plugin:  "pmsfdiskbackendplugin"
Using Wayland-EGL
[New Thread 0x7fffe7fff700 (LWP 24768)]
Using the 'xdg-shell' shell integration
[New Thread 0x7fffe77fe700 (LWP 24769)]

Thread 4 "partitionmanage" received signal SIG33, Real-time event 33.
[Switching to Thread 0x7fffe77fe700 (LWP 24769)]
0x00007ffff478af40 in g_atomic_ref_count_compare () from /usr/lib/libglib-2.0.so.0

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/bin/partitionmanager 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffeefe3700 (LWP 24772)]
Could not load plugin for core backend  "" :  "The shared library was not found."
Loaded backend plugin:  "pmsfdiskbackendplugin"
Using Wayland-EGL
[New Thread 0x7fffe7fff700 (LWP 24773)]
Using the 'xdg-shell' shell integration
[New Thread 0x7fffe77fe700 (LWP 24774)]

Thread 4 "DBusThread" received signal SIG33, Real-time event 33.
[Switching to Thread 0x7fffe77fe700 (LWP 24774)]
0x00007ffff61e4ab0 in malloc () from /usr/lib/libc.so.6

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/bin/partitionmanager 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffeefe3700 (LWP 24844)]
Could not load plugin for core backend  "" :  "The shared library was not found."
Loaded backend plugin:  "pmsfdiskbackendplugin"
Using Wayland-EGL
[New Thread 0x7fffe7fff700 (LWP 24845)]
Using the 'xdg-shell' shell integration
[New Thread 0x7fffe77fe700 (LWP 24846)]

Thread 2 "QDBusConnection" received signal SIG33, Real-time event 33.
[Switching to Thread 0x7fffeefe3700 (LWP 24844)]
0x00007ffff624fc21 in poll () from /usr/lib/libc.so.6
Comment 2 Andrius Štikonas 2019-02-05 19:42:41 UTC
Hmm, for now I still can't reproduce with

Qt 5.12.0
KDE Frameworks 5.54
KDE Plasma Version (Wayland): 5.14.90

So as you can see, a fairly similar versions.

Can you try without Wayland? It could be that you are hitting something else, but I'm not sure.

(I've been using Wayland for over a year, haven't seen any issues)
Comment 3 Lucia Mrenica 2019-02-05 19:48:17 UTC
It looks like on Plasma Xorg this problem doesn't occur and partitionmanager runs just fine.
Comment 4 Andrius Štikonas 2019-02-05 19:49:25 UTC
(In reply to mthw0 from comment #3)
> It looks like on Plasma Xorg this problem doesn't occur and partitionmanager
> runs just fine.

What about GNOME Wayland?
Comment 5 Lucia Mrenica 2019-02-05 19:54:08 UTC
Here is a video of how it looks like: https://gfycat.com/RealisticTinyAiredale
Comment 6 Lucia Mrenica 2019-02-05 19:58:38 UTC
On gnome wayland, It looks ugly and drops about half the frames, but other than that, it doesn't crash.
Comment 7 Lucia Mrenica 2019-02-05 20:07:58 UTC
After a further investigation it looks like I have this with every app that has a menu. So it is probably kwin or Qt bug and this can be closed then.
Comment 8 Andrius Štikonas 2019-02-05 20:13:14 UTC
(In reply to mthw0 from comment #7)
> After a further investigation it looks like I have this with every app that
> has a menu. So it is probably kwin or Qt bug and this can be closed then.

[20:09] <d_ed> stikonas: there are constant fixes to QtWayland wrt popup handling
[20:10] <d_ed> there's another one on review ATM
[20:11] <stikonas> I see. Strangely everything works fine for me in this case
[20:12] <d_ed> I would guess you have a newer Qt than the reporter
[20:12] <stikonas> actuallty older. I have QT 5.12.0, reporter has Qt 5.12.1
Comment 9 Andrius Štikonas 2019-02-05 20:59:10 UTC
Nouveau? https://bugs.archlinux.org/task/61638
Comment 10 Lucia Mrenica 2019-02-06 06:53:18 UTC
(In reply to Andrius Štikonas from comment #9)
> Nouveau? https://bugs.archlinux.org/task/61638

No, Intel HD 4400 with buit-in driver. Kernel 5.0.0-rc5
Comment 11 Johan Klokkhammer Helsing 2019-02-06 10:34:19 UTC
@mthw0: The dropping of frames on gnome-shell is likely this bug: https://gitlab.gnome.org/GNOME/mutter/issues/199

Also, do you know which patch fixed it for you? Perhaps this one? https://codereview.qt-project.org/#/c/252117/

Popups on Qt Wayland are a mess. There are restrictions in the xdg-shell protocol that match really poorly to the APIs we provide in Qt. In this case, it is probably the restriction that a new grabbing popup has to be the child of the current grabbing popup, combined with closing and opening sometimes happening in the opposite order.
Comment 12 Lucia Mrenica 2019-02-06 14:34:16 UTC
(In reply to Johan Klokkhammer Helsing from comment #11)
> @mthw0: The dropping of frames on gnome-shell is likely this bug:
> https://gitlab.gnome.org/GNOME/mutter/issues/199
> 
> Also, do you know which patch fixed it for you? Perhaps this one?
> https://codereview.qt-project.org/#/c/252117/
> 
> Popups on Qt Wayland are a mess. There are restrictions in the xdg-shell
> protocol that match really poorly to the APIs we provide in Qt. In this
> case, it is probably the restriction that a new grabbing popup has to be the
> child of the current grabbing popup, combined with closing and opening
> sometimes happening in the opposite order.

I am not sure whether I understand your question correctly. If you are asking, whether I have seen this patch, then yes, I've noticed it and it looks like it might be exactly what we need.
If you are asking whether I have tried building qt with it, then no, I have not. TBH I don't even know how.

Regarding Gnome, generally I would say it's a mess, and I am not convinced that it's caused by a single bug.
Comment 13 Johan Klokkhammer Helsing 2019-02-06 15:38:04 UTC
> If you are asking whether I have tried building qt with it, then no, I have not. TBH I don't even know how.

Yeah. Sorry, I just thought "resolved upstream" meant that you knew it was now fixed at the Qt level.

I see that it's just means that it's resolved as far as you're concerned and something that needs to be fixed upstream.
Comment 14 Lucia Mrenica 2019-02-06 19:43:21 UTC
(In reply to Johan Klokkhammer Helsing from comment #13)
> > If you are asking whether I have tried building qt with it, then no, I have not. TBH I don't even know how.
> 
> Yeah. Sorry, I just thought "resolved upstream" meant that you knew it was
> now fixed at the Qt level.
> 
> I see that it's just means that it's resolved as far as you're concerned and
> something that needs to be fixed upstream.

I managed to build qt5-wayland package with your patch and it seems to work, it does fix this issue.
Comment 15 Patrick Silva 2019-04-25 20:44:22 UTC
The problem persists at least with konsole.
I get the following message:

qt.qpa.wayland: setGrabPopup called with a parent, QtWaylandClient::QWaylandXdgSurface(0x55555593efd0) which does not match the current topmost grabbing popup, QtWaylandClient::QWaylandXdgSurface(0x555555993ec0) According to the xdg-shell protocol, this is not allowed. The wayland QPA plugin is currently handling it by setting the parent to the topmost grabbing popup. Note, however, that this may cause positioning errors and popups closing unxpectedly because xdg-shell mandate that child popups close before parents
Comment 16 Patrick Silva 2019-04-25 20:46:34 UTC
Operating System: Arch Linux 
KDE Plasma Version: 5.15.4
KDE Frameworks Version: 5.57.0
Qt Version: 5.13.0 beta2