Merge lp://qastaging/~vanvugt/unity/fix-918329-trunk into lp://qastaging/unity

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: no longer in the source branch.
Merged at revision: 1854
Proposed branch: lp://qastaging/~vanvugt/unity/fix-918329-trunk
Merge into: lp://qastaging/unity
Diff against target: 250 lines (+42/-55)
3 files modified
plugins/unityshell/src/compizminimizedwindowhandler.h (+23/-31)
plugins/unityshell/src/unityshell.cpp (+15/-23)
plugins/unityshell/src/unityshell.h (+4/-1)
To merge this branch: bzr merge lp://qastaging/~vanvugt/unity/fix-918329-trunk
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Approve
Unity Team Pending
Review via email: mp+89391@code.qastaging.launchpad.net

Description of the change

Fix SIGSEGV when a window is minimized. (LP: #918329)

The crash was caused by 'minimizedWindows' leaking pointers to windows that had been deleted, and then later trying to dereference those pointers. The reason for the leak appears to be a reference leak in the boost::shared_ptr's to CompizMinimizedWindowHandler. Reverting to regular pointers avoids the reference leak, avoids the crash, and makes the code easier to understand (and debug).

Detailed valgrind log showing the error:
https://bugs.launchpad.net/ubuntu/+source/unity/+bug/918329/comments/6

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Alright - so what do you think then? I'm in favor of using smart pointers where possible to do so, obviously we must use raw pointers in the list, but the list is managed by the destructor of the minimized window handler.

(I really need to clean up that file, but then again, the file probably represents how much of a hack fake minimization really is, which is the only way to get live previews from minimized windows *sigh*)

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I tried an in-between solution as you suggest, where the list is raw pointers and the share_ptrs stay in unityshell. It worked, however that necessitated some ugly dynamic typecasts. I think this version is better because the types are cleanly matched without casting required.

Smart pointers probably have their place. But in this case they caused leaks and made the code much harder to read and maintain.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

P.S. One of us just wasted a day because you forgot to mark the bug in progress or even assign it to yourself :(

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Fri, 20 Jan 2012, Daniel van Vugt wrote:

> I tried an in-between solution as you suggest, where the list is raw pointers and the share_ptrs stay in unityshell. It worked, however that necessitated some ugly dynamic typecasts. I think this version is better because the types are cleanly matched without casting required.
>
> Smart pointers probably have their place. But in this case they caused leaks and made the code much harder to read and maintain.

There is no need for dynamic casting as there is only a single line of
inheritance.

I'll merge this one though.

> --
> https://code.launchpad.net/~vanvugt/unity/fix-918329-trunk/+merge/89391
> You are requested to review the proposed merge of lp:~vanvugt/unity/fix-918329-trunk into lp:unity.
>

Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks.

And you're right about static casts instead of dynamic. But this version avoids all casts which is even better I think.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Fri, 20 Jan 2012, Daniel van Vugt wrote:

> Thanks.
>
> And you're right about static casts instead of dynamic. But this version avoids all casts which is even better I think.

Yes, boost::static_pointer_cast has the cost of the boost::shared_ptr
constructor (which is not that much, but something to dislike anyways).

I don't know why the static pointer casts were changed to dynamic casts.
That seems excessively silly, especially considering that one of them was
in a paint function (!). However, use of downcasting usually indicates a
problem with the design, one that should be revisited later (also related
to testing, since the base class exists for testing purposes)

> --
> https://code.launchpad.net/~vanvugt/unity/fix-918329-trunk/+merge/89391
> You are reviewing the proposed merge of lp:~vanvugt/unity/fix-918329-trunk into lp:unity.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.