Bug 396830 - kwin_x11 crash when suspending compositing
Summary: kwin_x11 crash when suspending compositing
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.14.4
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: Vlad Zahorodnii
URL:
Keywords: drkonqi
: 398018 400358 400881 400886 400954 401491 401559 401770 402317 423964 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-07-24 22:04 UTC by Anssi Hannula
Modified: 2020-09-22 11:47 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.15.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anssi Hannula 2018-07-24 22:04:52 UTC
Application: kwin_x11 (5.12.6)

Qt Version: 5.10.1
Frameworks Version: 5.47.0
Operating System: Linux 4.17.6-200.fc28.x86_64 x86_64
Distribution: "Fedora release 28 (Twenty Eight)"

-- Information about the crash:
- What I was doing when the application crashed:

I started game "FTL" via Steam and kwin_x11 crashed. From the backtrace it looks like compositing was being suspended and the crash occurred when effects were being unloaded.

I retried and the crash did not reoccur.

This is with the Intel drivers (HD Graphics 620 (Kaby Lake GT2)) and I have not customized kwin compositing settings.

The crash does not seem to be reproducible.

-- Backtrace:
Application: KWin (kwin_x11), signal: Aborted
Using host libthread_db library "/lib64/libthread_db.so.1".
28	  return SYSCALL_CANCEL (nanosleep, requested_time, remaining);
[Current thread is 1 (Thread 0x7f04d3fae940 (LWP 1925))]

Thread 4 (Thread 0x7f048fe09700 (LWP 2096)):
#0  0x00007f04cd4ac52c in futex_wait_cancelable (private=0, expected=0, futex_word=0x7f04d3303478 <QTWTF::pageheap_memory+57592>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  0x00007f04cd4ac52c in __pthread_cond_wait_common (abstime=0x0, mutex=0x7f04d3303428 <QTWTF::pageheap_memory+57512>, cond=0x7f04d3303450 <QTWTF::pageheap_memory+57552>) at pthread_cond_wait.c:502
#2  0x00007f04cd4ac52c in __pthread_cond_wait (cond=cond@entry=0x7f04d3303450 <QTWTF::pageheap_memory+57552>, mutex=mutex@entry=0x7f04d3303428 <QTWTF::pageheap_memory+57512>) at pthread_cond_wait.c:655
#3  0x00007f04d32159f8 in QTWTF::TCMalloc_PageHeap::scavengerThread() (this=0x7f04d32f5380 <QTWTF::pageheap_memory>) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2359
#4  0x00007f04d3215a63 in QTWTF::TCMalloc_PageHeap::runScavengerThread(void*) (context=<optimized out>) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1464
#5  0x00007f04cd4a6594 in start_thread (arg=<optimized out>) at pthread_create.c:463
#6  0x00007f04ca3200df in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7f04a6023700 (LWP 2078)):
#0  0x00007f04ca315756 in __GI_ppoll (fds=fds@entry=0x7f0494000d28, nfds=nfds@entry=1, timeout=<optimized out>, timeout@entry=0x0, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
#1  0x00007f04cb1dde55 in ppoll (__ss=<optimized out>, __timeout=<optimized out>, __nfds=<optimized out>, __fds=<optimized out>) at /usr/include/bits/poll2.h:77
#2  0x00007f04cb1dde55 in qt_ppoll (timeout_ts=0x0, nfds=1, fds=0x7f0494000d28) at kernel/qcore_unix.cpp:112
#3  0x00007f04cb1dde55 in qt_safe_poll(pollfd*, unsigned long, timespec const*) (fds=0x7f0494000d28, nfds=nfds@entry=1, timeout_ts=timeout_ts@entry=0x0) at kernel/qcore_unix.cpp:133
#4  0x00007f04cb1df159 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...) at ../../include/QtCore/../../src/corelib/tools/qarraydata.h:61
#5  0x00007f04cb19012b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7f04a6022c40, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:71
#6  0x00007f04cafde9c6 in QThread::exec() (this=<optimized out>) at thread/qthread.cpp:522
#7  0x00007f04d219f3a9 in QQmlThreadPrivate::run() (this=0x55a511756e40) at qml/ftw/qqmlthread.cpp:147
#8  0x00007f04cafe311d in QThreadPrivate::start(void*) (arg=0x55a511756e40) at thread/qthread_unix.cpp:376
#9  0x00007f04cd4a6594 in start_thread (arg=<optimized out>) at pthread_create.c:463
#10 0x00007f04ca3200df in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f04acd55700 (LWP 2034)):
#0  0x00007f04ca315756 in __GI_ppoll (fds=fds@entry=0x7f04a000e698, nfds=nfds@entry=1, timeout=<optimized out>, timeout@entry=0x0, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
#1  0x00007f04cb1dde55 in ppoll (__ss=<optimized out>, __timeout=<optimized out>, __nfds=<optimized out>, __fds=<optimized out>) at /usr/include/bits/poll2.h:77
#2  0x00007f04cb1dde55 in qt_ppoll (timeout_ts=0x0, nfds=1, fds=0x7f04a000e698) at kernel/qcore_unix.cpp:112
#3  0x00007f04cb1dde55 in qt_safe_poll(pollfd*, unsigned long, timespec const*) (fds=0x7f04a000e698, nfds=nfds@entry=1, timeout_ts=timeout_ts@entry=0x0) at kernel/qcore_unix.cpp:133
#4  0x00007f04cb1df159 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...) at ../../include/QtCore/../../src/corelib/tools/qarraydata.h:61
#5  0x00007f04cb19012b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7f04acd54c30, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:71
#6  0x00007f04cafde9c6 in QThread::exec() (this=<optimized out>) at thread/qthread.cpp:522
#7  0x00007f04d406e299 in QDBusConnectionManager::run() (this=0x7f04d40e5060 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at qdbusconnection.cpp:178
#8  0x00007f04cafe311d in QThreadPrivate::start(void*) (arg=0x7f04d40e5060 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at thread/qthread_unix.cpp:376
#9  0x00007f04cd4a6594 in start_thread (arg=<optimized out>) at pthread_create.c:463
#10 0x00007f04ca3200df in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f04d3fae940 (LWP 1925)):
[KCrash Handler]
#6  0x00007f04ca25cfeb in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#7  0x00007f04ca2475c1 in __GI_abort () at abort.c:79
#8  0x00007f04ca247491 in __assert_fail_base (fmt=0x7f04ca3aa248 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7f04cc741688 "0 && \"Couldn't find current GLX or EGL context.\\n\"", file=0x7f04cc7415e0 "../src/dispatch_common.c", line=858, function=0x7f04cc7416c0 <__PRETTY_FUNCTION__.38150> "epoxy_get_proc_address") at assert.c:92
#9  0x00007f04ca255752 in __GI___assert_fail (assertion=assertion@entry=0x7f04cc741688 "0 && \"Couldn't find current GLX or EGL context.\\n\"", file=file@entry=0x7f04cc7415e0 "../src/dispatch_common.c", line=line@entry=858, function=function@entry=0x7f04cc7416c0 <__PRETTY_FUNCTION__.38150> "epoxy_get_proc_address") at assert.c:101
#10 0x00007f04cc71c74f in epoxy_get_proc_address (name=0x7f04cc72fc7c <entrypoint_strings+9692> "glDeleteProgram") at ../src/dispatch_common.c:858
#11 0x00007f04cc6f16ba in epoxy_glDeleteProgram_resolver () at src/gl_generated_dispatch.c:80418
#12 0x00007f04cc6f16ba in epoxy_glDeleteProgram_global_rewrite_ptr (program=7) at src/gl_generated_dispatch.c:47996
#13 0x00007f04d3344064 in KWin::BlurEffect::~BlurEffect() (this=0x55a511f4b070, __in_chrg=<optimized out>) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/effects/blur/blur.cpp:86
#14 0x00007f04d334414d in KWin::BlurEffect::~BlurEffect() (this=0x55a511f4b070, __in_chrg=<optimized out>) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/effects/blur/blur.cpp:82
#15 0x00007f04d39f579a in KWin::EffectsHandlerImpl::unloadAllEffects() (this=this@entry=0x55a511ae9380) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/effects.cpp:280
#16 0x00007f04d39f583b in KWin::EffectsHandlerImpl::~EffectsHandlerImpl() (this=0x55a511ae9380, __in_chrg=<optimized out>) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/effects.cpp:263
#17 0x00007f04ac33109c in KWin::EffectsHandlerImplX11::~EffectsHandlerImplX11() (this=0x55a511ae9380, __in_chrg=<optimized out>) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/xcbutils.h:1470
#18 0x00007f04ac33116d in KWin::EffectsHandlerImplX11::~EffectsHandlerImplX11() (this=0x55a511ae9380, __in_chrg=<optimized out>) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/plugins/platforms/x11/standalone/effects_x11.h:33
#19 0x00007f04d39d647f in KWin::Compositor::finish() (this=0x55a511609f90) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/composite.cpp:408
#20 0x00007f04d39d6a40 in KWin::Compositor::suspend(KWin::Compositor::SuspendReason) (this=0x55a511609f90, reason=<optimized out>) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/composite.cpp:576
#21 0x00007f04cb1baa26 in QObject::event(QEvent*) (this=0x55a511609f90, e=<optimized out>) at kernel/qobject.cpp:1247
#22 0x00007f04cba58e95 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x55a511497fd0, receiver=receiver@entry=0x55a511609f90, e=e@entry=0x55a512e9eca0) at kernel/qapplication.cpp:3732
#23 0x00007f04cba6083a in QApplication::notify(QObject*, QEvent*) (this=0x7fff42fb9a40, receiver=0x55a511609f90, e=0x55a512e9eca0) at kernel/qapplication.cpp:3491
#24 0x00007f04cb191376 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x55a511609f90, event=0x55a512e9eca0) at kernel/qcoreapplication.cpp:1050
#25 0x00007f04cb19409b in QCoreApplication::sendEvent(QObject*, QEvent*) (event=0x55a512e9eca0, receiver=0x0) at kernel/qcoreapplication.h:234
#26 0x00007f04cb19409b in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=0x0, event_type=0, data=0x55a5114840f0) at kernel/qcoreapplication.cpp:1740
#27 0x00007f04cb1defcf in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55a511506790, flags=...) at kernel/qeventdispatcher_unix.cpp:466
#28 0x00007f04af553321 in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...) at qunixeventdispatcher.cpp:68
#29 0x00007f04cb19012b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7fff42fb9950, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:71
#30 0x00007f04cb1985b6 in QCoreApplication::exec() () at kernel/qcoreapplication.cpp:1338
#31 0x00007f04d3d7693f in kdemain(int, char**) (argc=<optimized out>, argv=0x7fff42fb9bd8) at /usr/src/debug/kwin-5.12.6-1.fc28.x86_64/main_x11.cpp:468
#32 0x00007f04ca24924b in __libc_start_main (main=0x55a510a7eca0 <main>, argc=3, argv=0x7fff42fb9bd8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff42fb9bc8) at ../csu/libc-start.c:308
#33 0x000055a510a7ecda in _start ()

Possible duplicates by query: bug 386263, bug 385142, bug 382799, bug 376360, bug 376115.

Reported using DrKonqi
Comment 1 henk717 2018-09-19 17:25:25 UTC
I am experiencing the same issue on Kubuntu 18.04 , KDE Plasma 5.12.6.
When starting a game trough steam that disables compositing there is a chance that kwin_x11 stops working. I am unable to locate a crash dump or log entry of this event. When using Alt + F2 to manually start kwin_x11 the system resumes functioning normally and then i am unable to reproduce the bug. I have not been able to find out why the crash only occurs some of the times a game is ran but rarely happens after a reboot or restart of kwin_x11.

Kwin support information: https://paste.kde.org/pxajs4zhr
Comment 2 Mahendra Tallur 2018-10-21 21:28:38 UTC
Hi ! I regularly (maybe once every 1-2 days ?) encounter a kwin crash (decorations disappear, I have to restart kwin manually) when starting a game that disables compositing (or switching mpv to fullscreen).

I yet have to figure out a way to reproduce it... But it's been happening for at least 6 months - 1 year and is still the case when using the whole up to date KDE stack and Neon 18.04. (whether I use a PPA or not)

It occurs with both Intel HD Graphics and AMD Radeon RX550/560 (but not with Nvidia, but those are not that pleasant to use under KDE :). It happens in both Neon 16.04 and 18.04. And also with a recent kernel in Manjaro. It occurs on several different PCs. 

How can I help pinpoint this ? Are there other related bug reports ? 
Cheers :-)
Comment 3 Martin Flöser 2018-10-27 15:53:47 UTC
*** Bug 400358 has been marked as a duplicate of this bug. ***
Comment 4 Vlad Zahorodnii 2018-11-03 20:24:07 UTC
I can always reproduce it by doing the following:
* Run kwin from terminal, e.g. kwin_x11 --replace
* Activate the Present Windows effect, hover some window
* Activate the Desktop Grid effect
* Replace kwin by running kwin_x11 --replace from krunner
Comment 5 Vlad Zahorodnii 2018-11-03 20:28:53 UTC
*** Bug 398018 has been marked as a duplicate of this bug. ***
Comment 6 Mahendra Tallur 2018-11-09 13:02:14 UTC
Hi ! I have a problem getting a proper debug trace...
I frequently get the crash when gdb is not attached to kwin (I usually kill & start kwin from gdb).
However when I try to attach gdb from the pre-existing kwin process, the system hangs. Any idea ?

Also, for some reason, I never get DrKonqi when my decorations disappear.
As a dirty and not that satisfying workaround, could kwin auto-restart when it crashes ?
Comment 7 Vlad Zahorodnii 2018-11-09 13:06:51 UTC
(In reply to Mahendra Tallur from comment #6)
> However when I try to attach gdb from the pre-existing kwin process, the
> system hangs. Any idea ?
Did you resume kwin? e.g.
    (gdb) continue

Also, I think this bug report already has good backtrace.
Comment 8 Mahendra Tallur 2018-11-09 13:15:07 UTC
(In reply to Vlad Zagorodniy from comment #7)
> (In reply to Mahendra Tallur from comment #6)
> > However when I try to attach gdb from the pre-existing kwin process, the
> > system hangs. Any idea ?
> Did you resume kwin? e.g.
>     (gdb) continue
> 
> Also, I think this bug report already has good backtrace.

Nope, I cannot resume, I cannot activate the terminal. OK, I have to do it from the full screen console, gonna check the right syntax...

I think the problem is that kwin devs are not gamers and thus cannot experience it themselves ;) -- it's true it's difficult to be productive & gamer :)
Comment 9 Vlad Zahorodnii 2018-11-09 19:24:39 UTC
*** Bug 400881 has been marked as a duplicate of this bug. ***
Comment 10 Vlad Zahorodnii 2018-11-09 20:43:24 UTC
*** Bug 400886 has been marked as a duplicate of this bug. ***
Comment 11 Vlad Zahorodnii 2018-11-12 08:34:28 UTC
*** Bug 400954 has been marked as a duplicate of this bug. ***
Comment 12 Martin Flöser 2018-11-28 05:18:48 UTC
*** Bug 401491 has been marked as a duplicate of this bug. ***
Comment 13 Vlad Zahorodnii 2018-11-30 09:35:03 UTC
*** Bug 401559 has been marked as a duplicate of this bug. ***
Comment 14 Vlad Zahorodnii 2018-12-05 14:53:19 UTC
*** Bug 401770 has been marked as a duplicate of this bug. ***
Comment 15 Vlad Zahorodnii 2018-12-12 11:58:03 UTC
(In reply to Vlad Zagorodniy from comment #4)
> I can always reproduce it by doing the following:
> * Run kwin from terminal, e.g. kwin_x11 --replace
> * Activate the Present Windows effect, hover some window
> * Activate the Desktop Grid effect
> * Replace kwin by running kwin_x11 --replace from krunner

Weird, I'm not able anymore to reproduce the crash by following these steps.

If you're able to reproduce this crash, could you please provide the following details:
* version of libepoxy;
* version of KWin;
* what GPU and driver you use;
* what were you doing to reproduce the crash;
* is the crash reproducible in the following scenarios:
   - Background Contrast effect disabled / Blur effect disabled;
   - Background Contrast effect disabled / Blur effect enabled;
   - Background Contrast effect enabled  / Blur effect disabled;
   - Background Contrast effect enabled  / Blur effect enabled.

Thanks.
Comment 16 Vlad Zahorodnii 2018-12-19 11:42:13 UTC
*** Bug 402317 has been marked as a duplicate of this bug. ***
Comment 17 Vlad Zahorodnii 2018-12-19 12:49:56 UTC
I added some debug outputs(https://phabricator.kde.org/P282) to see what the current OpenGL context is when the blur effect is about to be destroyed, and results are somewhat odd:

  About to unload all effects
  Current context: 0x55940fcbdbe0
  Current context: 0x55940fcbdbe0
  About to destroy the blur effect
  Current context: 0x0
  Current context: 0x55940fcbdbe0

It looks like the context somehow got released.
Comment 18 Vlad Zahorodnii 2018-12-19 14:05:14 UTC
It looks like QQuickView messes with the current context.
Comment 19 Vlad Zahorodnii 2018-12-19 14:13:58 UTC
Current workaround: Disable close buttons in the Present Windows effect.
Comment 20 Vlad Zahorodnii 2018-12-21 00:22:38 UTC
Git commit 9ac2e5d5bb44934b6d30bda9315210d544f33958 by Vlad Zagorodniy.
Committed on 21/12/2018 at 00:22.
Pushed by vladz into branch 'master'.

[effects] Make current OpenGL context per each unloaded effect

Summary:
Some effects may release the current context when they tear down, so we
have to make the current context per each unloaded effect.
FIXED-IN: 5.15.0

Test Plan: No longer able to reproduce bug 396830.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

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

M  +36   -32   effects.cpp
M  +2    -0    effects.h

https://commits.kde.org/kwin/9ac2e5d5bb44934b6d30bda9315210d544f33958
Comment 21 Mahendra Tallur 2018-12-21 20:27:22 UTC
@Vlad : thank you so much for this important fix ! 
As a Neon user edition... user, is the provided workaround a proper way of confirming the fix works ? I'll try hard to reproduce it ! 

Can anyone confirm this bug also affect the LTS version of Plasma ?

Thanks again,
cheers,
Mahen
Comment 22 Mahendra Tallur 2018-12-21 20:30:16 UTC
Replying to myself : 
yes, this bug affects the LTS too (several reporters) -- I'll think twice before posting. Would it be possible to backport the fix to 5.12 and possibly the current 5.14 too ?

Cheers & thanks again for figuring it out, it's been turning me crazy !
Comment 23 Vlad Zahorodnii 2020-09-22 11:47:56 UTC
*** Bug 423964 has been marked as a duplicate of this bug. ***