Bug 380392 - KWindowSystem::setMainWindow kills new parent on deletion with Qt 5.9
Summary: KWindowSystem::setMainWindow kills new parent on deletion with Qt 5.9
Status: RESOLVED UPSTREAM
Alias: None
Product: frameworks-kwindowsystem
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.34.0
Platform: Other Linux
: NOR critical
Target Milestone: ---
Assignee: Martin Flöser
URL:
Keywords:
: 379624 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-05-31 13:05 UTC by Fabian Vogt
Modified: 2017-06-07 21:55 UTC (History)
7 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 Fabian Vogt 2017-05-31 13:05:11 UTC
Qt 5.9 changed the behaviour of destructing foreign QWindow instances,
which results in child window destructors somehow causing X11 BadWindow errors.

Those crash the parent app, so libreoffice, chromium and firefox.
This makes it impossible to open or save documents.

A workaround is to disable the connection, but that causes a memory leak AFAICT.

I'm not sure whether the actual underlying bug is on Qt side or KDE side.

See also https://github.com/openSUSE/kmozillahelper/issues/14
Comment 1 David Edmundson 2017-05-31 13:14:08 UTC
If you're reporting a crash, upload a backtrace.

>X11 BadWindow errors.

That warning wouldn't (or shouldn't) cause a crash. I doubt it's related.
Comment 2 Fabian Vogt 2017-05-31 15:21:00 UTC
(In reply to David Edmundson from comment #1)
> If you're reporting a crash, upload a backtrace.
> 
> >X11 BadWindow errors.
> 
> That warning wouldn't (or shouldn't) cause a crash. I doubt it's related.

The firefox crash is a result of GDK giving up and trying to make a coredump.
Sometimes it shows a helpful message though:

Gdk-WARNING **: GdkWindow 0x3400010 unexpectedly destroyed

eang hit a very likely related issue: The akonadi agent configuration dialogs in kmail cause the parent window to get hidden when closing. It's impossible to show the configuration window again after that. XCB BadWindow messages appear on stderr when it happens. I can reliably reproduce this issue as well.

Setting as confirmed due to this.

Curiously, kdialog --attach is not affected, at least not reliably. lucab reported some crashes, but can't reproduce them. I guess that the destruction of windows in kdialog happens in a different order.
Comment 3 Jonathan Marten 2017-05-31 17:24:35 UTC
Same happens here with Qt 5.9 and the KIO cookie dialogue (with cookie option set to "Ask for confirmation").  Starting Konqueror and going to a website which will set a cookie opens the main window, then the cookie dialogue on top of it, then closes the main window when a button is pressed and the cookie dialogue closes.  The Konqueror process continues running, as shown by the HTTP fetching and rendering continuing, but the window is hidden.

There are usually about 6-8 "BadWindow" message shown, but no crash.
Comment 4 Fabian Vogt 2017-05-31 17:52:25 UTC
Just did some tests with gdb and a breakpoint on xcb_destroy_window.
The result is that Qt 5.9 actually calls it for foreign windows (also for kdialog, but for some reason tha shows less ill effects) while Qt 5.7 (likely 5.8 as well) does not.

I'll try to produce a minimal testcase as likely expected by upstream Qt, report it and link it here.
Comment 5 Elvis Angelaccio 2017-05-31 17:58:35 UTC
*** Bug 379624 has been marked as a duplicate of this bug. ***
Comment 6 Christoph Feck 2017-06-07 21:55:02 UTC
Bug has been accepted upstream, and a patch has been merged to 5.9 branch, see https://codereview.qt-project.org/#/c/196296/