Merge lp:~vanvugt/compiz/fix-1019337.2 into lp:compiz/0.9.8

Proposed by Daniel van Vugt
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 3286
Merged at revision: 3286
Proposed branch: lp:~vanvugt/compiz/fix-1019337.2
Merge into: lp:compiz/0.9.8
Diff against target: 17 lines (+3/-0)
1 file modified
gtk/window-decorator/wnck.c (+3/-0)
To merge this branch: bzr merge lp:~vanvugt/compiz/fix-1019337.2
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
jenkins (community) continuous-integration Approve
Review via email: mp+114597@code.launchpad.net

Commit message

Fix crash LP: #1019337 properly this time.

The original fix did not handle the case where:
    (win != NULL && xid != None && !valid_window(xid))
so would still exit with an X error.

Now we trap and handle such errors gracefully, instead of hitting the
default handler which kills gtk-window-decorator.

Description of the change

Fix crash LP: #1019337 properly this time.

The original fix did not handle the case where:
    (win != NULL && xid != None && !valid_window(xid))
so would still exit with an X error.

Now we trap and handle such errors gracefully, instead of hitting the
default handler which kills gtk-window-decorator.

UNBLOCK

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Also good,

23 if (result == Success && error == Success && data)

I don't think there's a reason to check for result and error being Success here - my understanding of the protocol is that XGetWindowProperty is a synchronous call and returns its error code (in this case being Success, BadValue, BadAtom or BadWindow) (http://www.x.org/docs/XProtocol/proto.pdf)). However, the error traps are necessary because we don't want the process to abort.

We should find other unguarded X Protocol calls which may also generate such errors too and guard them as well.

If it turns out that the actual XErrorEvent trapped may return something different to XGetWindowProperty then it's an Approve from me, otherwise remove the other redundant check and consider it Approved.

(No tests required in gtk-window-decorator now, there is no testing framework for it)

Revision history for this message
Tim Penhey (thumper) wrote :

I'm not going to comment on which result is more important, I just notice that gdk_error_trap_pop is defined to return either X error code or 0 on success.

We are comparing the X function return (an int) against Success, and the g_ func return (a gint) against Success. I suggest we change the error check to be (error == 0). Even if Success is defined to be zero somewhere, I think this makes the API clearer.

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

In X error codes, "Success" is what you're meant to use:

% grep "#define Success" /usr/include/X11/X.h
#define Success 0 /* everything's okay */

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

Yes, it is possible result != error. Because all the docs I found said that result is either Success or undefined. However 'error' tells you what the error was.

However it's a moot point since all we're testing for is Success. So there's no need to check 'error == Success' too. It's redundant but harmless.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks safe. Didier also pointed that it can't possibly do any harm, so I'm approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gtk/window-decorator/wnck.c'
2--- gtk/window-decorator/wnck.c 2012-07-11 04:34:54 +0000
3+++ gtk/window-decorator/wnck.c 2012-07-16 05:39:21 +0000
4@@ -50,10 +50,13 @@
5 if (xid == None)
6 return "bare";
7
8+ gdk_error_trap_push ();
9 result = XGetWindowProperty (gdk_x11_get_default_xdisplay (), xid,
10 net_wm_state_atom,
11 0L, 1024L, FALSE, XA_ATOM, &actual, &format,
12 &n, &left, &data);
13+ gdk_flush ();
14+ gdk_error_trap_pop ();
15
16 if (result == Success && data)
17 {

Subscribers

People subscribed via source and target branches