[PATCH] smoke:fix the segment fault error

Juan Zhao juan.j.zhao at linux.intel.com
Thu Feb 2 16:45:32 PST 2012


The segment fault error is caused by a null surface inside smoke, but
not inside that desktop shell. Just initializing the widget size can
help to create the right surface. 

Here is the backtrace infomation of that segment fault error:

[3695783.129]  -> wl_shell at 8.get_shell_surface(new id 23, wl_surface at 22)
mmap failed: Invalid argument

Program received signal SIGSEGV, Segmentation fault.
*INT_cairo_image_surface_get_data (surface=0x0) at
cairo-image-surface.c:552
552	    if (! _cairo_surface_is_image (surface)) {
(gdb) bt
#0  *INT_cairo_image_surface_get_data (surface=0x0) at
cairo-image-surface.c:552
#1  0x0804c04f in render (data=0xbffff6b8, callback=0x0, time=0) at
smoke.c:155
#2  frame_callback (data=0xbffff6b8, callback=0x0, time=0) at
smoke.c:203
#3  0x0804b733 in main (argc=1, argv=0xbffff7b4) at smoke.c:296


On Thu, 2012-02-02 at 16:13 +0100, Tiago Vignatti wrote:
> why do not cap that in the compositor instead?
> 
> @ -326,9 +326,13 @@ shell_surface_resize(struct wl_client *client, 
> struct wl_re
>                       struct wl_resource *input_resource, uint32_t time,
>                       uint32_t edges)
>   {
> -       struct weston_input_device *wd = input_resource->data;
> +       struct weston_input_device *wd;
>          struct shell_surface *shsurf = resource->data;
> 
> +       if (!input_resource)
> +               return;
> +
> +       wd = input_resource->data;
> 
> 
> On 02/03/2012 01:02 AM, juan.j.zhao at linux.intel.com wrote:
> > From: Juan Zhao<juan.j.zhao at linux.intel.com>
> >
> > Add widget_set_size in the initiate time to allow smoke get the
> >   correct surface later. Or it will report segment fault error
> >   because of the null surface.
> > Also add resize_handler to not allow resizing just like flower.
> >
> > Signed-off-by: Juan Zhao<juan.j.zhao at linux.intel.com>
> > ---
> >   clients/smoke.c |   12 ++++++++++++
> >   1 files changed, 12 insertions(+), 0 deletions(-)
> >
> > diff --git a/clients/smoke.c b/clients/smoke.c
> > index c1665ce..69a1ac7 100644
> > --- a/clients/smoke.c
> > +++ b/clients/smoke.c
> > @@ -249,6 +249,16 @@ smoke_motion_handler(struct widget *widget, struct input *input,
> >   	return POINTER_HAND1;
> >   }
> >
> > +static void
> > +resize_handler(struct widget *widget,
> > +	       int32_t width, int32_t height, void *data)
> > +{
> > +	struct smoke *smoke = data;
> > +
> > +	/* Dont resize me */
> > +	widget_set_size(smoke->widget, smoke->width, smoke->height);
> > +}
> > +
> >   int main(int argc, char *argv[])
> >   {
> >   	struct timespec ts;
> > @@ -270,6 +280,7 @@ int main(int argc, char *argv[])
> >   	smoke.window = window_create(d);
> >   	smoke.widget = window_add_widget(smoke.window,&smoke);
> >   	window_set_title(smoke.window, "smoke");
> > +	widget_set_size(smoke.widget, smoke.width, smoke.height);
> >
> >   	window_set_buffer_type(smoke.window, WINDOW_BUFFER_TYPE_SHM);
> >   	clock_gettime(CLOCK_MONOTONIC,&ts);
> > @@ -291,6 +302,7 @@ int main(int argc, char *argv[])
> >   	window_flush(smoke.window);
> >
> >   	widget_set_motion_handler(smoke.widget, smoke_motion_handler);
> > +	widget_set_resize_handler(smoke.widget, resize_handler);
> >
> >   	window_set_user_data(smoke.window,&smoke);
> >   	frame_callback(&smoke, NULL, 0);
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel




More information about the wayland-devel mailing list