After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 746510 - wayland: Fix damage of infinite regions
wayland: Fix damage of infinite regions
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2015-03-20 07:13 UTC by Jonas Ådahl
Modified: 2015-03-31 07:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wayland: Fix damage of infinite regions (1.68 KB, patch)
2015-03-20 07:14 UTC, Jonas Ådahl
none Details | Review
wayland: Fix damage of infinite regions (2.22 KB, patch)
2015-03-26 06:55 UTC, Jonas Ådahl
committed Details | Review

Description Jonas Ådahl 2015-03-20 07:13:58 UTC
Don't try to scale INT32_MAX x INT32_MAX damage regions.
Comment 1 Jonas Ådahl 2015-03-20 07:14:02 UTC
Created attachment 299918 [details] [review]
wayland: Fix damage of infinite regions

Infinte regions (0, 0) -> (INT32_MAX, INT32_MAX) were still scaled,
causing integer overflow.
Comment 2 Rui Matos 2015-03-20 13:32:57 UTC
Review of attachment 299918 [details] [review]:

The overflow might still happen in meta_region_scale() if a (dumb?) client sends us big enough values.

Perhaps we should sanitize the rects in wl_surface_damage() as they come in, intersecting them with the surface rect?
Comment 3 Jonas Ådahl 2015-03-22 03:07:56 UTC
(In reply to Rui Matos from comment #2)
> Review of attachment 299918 [details] [review] [review]:
> 
> The overflow might still happen in meta_region_scale() if a (dumb?) client
> sends us big enough values.
> 
> Perhaps we should sanitize the rects in wl_surface_damage() as they come in,
> intersecting them with the surface rect?

Yes I suppose we could do that. I'll update the patch.
Comment 4 Jasper St. Pierre (not reading bugmail) 2015-03-22 03:11:17 UTC
When do we have infinite damage?
Comment 5 Jonas Ådahl 2015-03-22 03:42:18 UTC
When the client uses the method eglSwapBuffers without damage.(In reply to Jasper St. Pierre from comment #4)
> When do we have infinite damage?

EGL clients.
Comment 6 drago01 2015-03-25 21:01:21 UTC
(In reply to Jasper St. Pierre from comment #4)
> When do we have infinite damage?

Yes that dumb mesa hack.
Comment 7 Jonas Ådahl 2015-03-26 06:55:38 UTC
Created attachment 300333 [details] [review]
wayland: Fix damage of infinite regions

To avoid integer overflow when scaling "infinite" regions (0, 0)
(INT32_MAX, INT32_MAX), intersect with the surface rect before scaling,
instead of intersecting with the buffer rect afterwards.
Comment 8 Rui Matos 2015-03-26 10:20:17 UTC
Review of attachment 300333 [details] [review]:

::: src/wayland/meta-wayland-surface.c
@@ +136,3 @@
+  buffer_width = cogl_texture_get_width (surface->buffer->texture);
+  buffer_height = cogl_texture_get_height (surface->buffer->texture);
+  surface_rect = (cairo_rectangle_int_t) {

Surely surface_rect's (lack of) initialization above means that .x and .y have undefined values here?

Also, FWIW, we don't use this kind of struct assignment anywhere (AFAIK) in mutter though I don't personally mind it.
Comment 9 Jonas Ådahl 2015-03-26 10:43:52 UTC
(In reply to Rui Matos from comment #8)
> Review of attachment 300333 [details] [review] [review]:
> 
> ::: src/wayland/meta-wayland-surface.c
> @@ +136,3 @@
> +  buffer_width = cogl_texture_get_width (surface->buffer->texture);
> +  buffer_height = cogl_texture_get_height (surface->buffer->texture);
> +  surface_rect = (cairo_rectangle_int_t) {
> 
> Surely surface_rect's (lack of) initialization above means that .x and .y
> have undefined values here?

Actually in C99 .x and .y will be initialized to 0 here.

> 
> Also, FWIW, we don't use this kind of struct assignment anywhere (AFAIK) in
> mutter though I don't personally mind it.

Personally I prefer this declarative kind of definitions.
Comment 10 Jasper St. Pierre (not reading bugmail) 2015-03-26 15:39:18 UTC
I've used it before in mutter. I really like the construction, and wish we could use it more. It's known as a "compound literal".

https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Compound-Literals.html
Comment 11 Rui Matos 2015-03-30 09:18:40 UTC
Review of attachment 300333 [details] [review]:

(In reply to Jonas Ådahl from comment #9)
> Actually in C99 .x and .y will be initialized to 0 here.

Indeed, cool. And Jasper likes it too so let's not delay this
Comment 12 Jonas Ådahl 2015-03-31 07:11:59 UTC
Attachment 300333 [details] pushed as dbca333 - wayland: Fix damage of infinite regions