[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-31 Thread Vlad Zahorodnii
https://bugs.kde.org/show_bug.cgi?id=411049

Vlad Zahorodnii  changed:

   What|Removed |Added

 Status|REPORTED|RESOLVED
  Latest Commit||https://commits.kde.org/kwi
   ||n/d2bbd2a124846853748e1cb72
   ||e0e39f0cd8ae26f
 Resolution|--- |FIXED

--- Comment #8 from Vlad Zahorodnii  ---
Git commit d2bbd2a124846853748e1cb72e0e39f0cd8ae26f by Vlad Zagorodniy.
Committed on 31/08/2019 at 10:31.
Pushed by vladz into branch 'master'.

[x11] Fix crash during tear down

Summary:
Any call made to a virtual method in constructor/destructor of a base
class won't go to a derived class because the base class may access
uninitialized or destroyed resources.

For example, let's consider the following two classes

class Base {
public:
Base() { foo()->bar(); }
virtual ~Base() { foo()->bar(); }

virtual Foo* foo() const { return nullptr; }
};

class Derived : public Base {
public:
Derived() : mFoo(new Foo) {}
~Derived() override { delete mFoo; }

Foo* foo() const override { return mFoo; }

private:
Foo* mFoo;
};

When an instance of Derived class is created, constructors will run in
the following order:

Base()
Derived()

It's not safe to dispatch foo() method call to Derived class because
constructor of Derived hasn't initialized yet mFoo.

Same story with destructors, they'll run in the following order:

~Derived()
~Base()

It's not safe to dispatch foo() method call in the destructor of Base
class to Derived class because mFoo was deleted.

So, what does that weird C++ behavior has something to do with KWin? Well,
recently Compositor class was split into two classes - WaylandCompositor,
and X11Compositor. Some functionality from X11 doesn't make sense on
Wayland. Therefore methods that implement that stuff were "purified," i.e.
they became pure virtual methods. Unfortunately, when Compositor tears
down it may call pure virtual methods on itself. Given that those calls
cannot be dispatched to X11Compositor or WaylandCompositor, the only
choice that C++ runtime has is to throw an exception.

The fix for this very delicate problem is very simple - do not call virtual
methods from constructors and the destructor. Avoid doing that if you can!

This change moves Compositor::updateClientCompositeBlocking to X11Compositor
so it longer has to be a virtual method. Also, it kind of doesn't make sense
to keep it in base Compositor class because compositing can be blocked only
on X11.

Test Plan: KWin no longer crashes when running kwin_x11 --replace command.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: anthonyfieroni, kwin

Tags: #kwin

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

M  +5-16   composite.cpp
M  +3-9composite.h
M  +8-3workspace.cpp

https://commits.kde.org/kwin/d2bbd2a124846853748e1cb72e0e39f0cd8ae26f

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-20 Thread Vlad Zahorodnii
https://bugs.kde.org/show_bug.cgi?id=411049

--- Comment #7 from Vlad Zahorodnii  ---
(In reply to Martin Flöser from comment #5)
> What we can see is the previous KWin instance crashing on tear down.
kwin crashes starting from this change 1db84a2ba71657a26d2a7971eb0c35e2716742c3

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-20 Thread Vlad Zahorodnii
https://bugs.kde.org/show_bug.cgi?id=411049

--- Comment #6 from Vlad Zahorodnii  ---
@Martin This crash happens because kwin calls a pure virtual method from
destructor of a base class. See https://phabricator.kde.org/D23098

The proposed patch works around the problem.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-19 Thread Martin Flöser
https://bugs.kde.org/show_bug.cgi?id=411049

Martin Flöser  changed:

   What|Removed |Added

 Resolution|BACKTRACE   |---
 Status|NEEDSINFO   |REPORTED

--- Comment #5 from Martin Flöser  ---
Backtrace is better. What we can see is the previous KWin instance crashing on
tear down.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-19 Thread Tony
https://bugs.kde.org/show_bug.cgi?id=411049

--- Comment #4 from Tony  ---
Created attachment 122246
  --> https://bugs.kde.org/attachment.cgi?id=122246&action=edit
I thought they were installed since i did not get the prompt to do so. Anyways
here it is with debug symbols.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-18 Thread Martin Flöser
https://bugs.kde.org/show_bug.cgi?id=411049

Martin Flöser  changed:

   What|Removed |Added

 Resolution|--- |BACKTRACE
 Status|REPORTED|NEEDSINFO

--- Comment #3 from Martin Flöser  ---
Unfortunately the backtrace is lacking debug symbols. if you are able to
reproduce please install debug packages and attach a new backtrace.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-18 Thread Tony
https://bugs.kde.org/show_bug.cgi?id=411049

--- Comment #2 from Tony  ---
Created attachment 122238
  --> https://bugs.kde.org/attachment.cgi?id=122238&action=edit
Better bactrace?

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-18 Thread Tony
https://bugs.kde.org/show_bug.cgi?id=411049

Tony  changed:

   What|Removed |Added

 CC||jodr...@live.com

-- 
You are receiving this mail because:
You are watching all bug changes.

[kwin] [Bug 411049] Kwin crash after turn off "Sync to VBlank"

2019-08-18 Thread Tony
https://bugs.kde.org/show_bug.cgi?id=411049

--- Comment #1 from Tony  ---
Created attachment 122236
  --> https://bugs.kde.org/attachment.cgi?id=122236&action=edit
How to

-- 
You are receiving this mail because:
You are watching all bug changes.