[PATCH weston] Destroy resources when destroying an output

Jason Ekstrand jason at jlekstrand.net
Thu May 8 17:32:42 PDT 2014


On Thu, May 8, 2014 at 1:07 PM, Mariusz Ceier <mceier+wayland at gmail.com>wrote:

> Hi,
>    I sent similar patch in the past, and this reply from Pekka may be
> still relevant:
>
> http://lists.freedesktop.org/archives/wayland-devel/2013-December/012691.html
>

See the reply I just sent out to the above e-mail.
--Jason Ekstrand


>
> Mariusz Ceier
>
>
> On 8 May 2014 19:38, Neil Roberts <neil at linux.intel.com> wrote:
> > When an output is destroyed it now also destroys any resources that
> > were pointing to it. Otherwise if the resource is destroyed after the
> > output then the resource would try to remove itself from the resource
> > list but the head of the resource list would no longer be valid and it
> > would write to invalid memory.
> >
> > This was found using Valgrind. It looks like there is a similar
> > problem for weston_pointer_destroy and in that case there is even a
> > comment suggesting we should do something about it.
> >
> > https://bugs.freedesktop.org/show_bug.cgi?id=78415
> > ---
> >  src/compositor.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/src/compositor.c b/src/compositor.c
> > index cd1ca9a..4162315 100644
> > --- a/src/compositor.c
> > +++ b/src/compositor.c
> > @@ -3110,6 +3110,8 @@ weston_compositor_remove_output(struct
> weston_compositor *compositor,
> >  WL_EXPORT void
> >  weston_output_destroy(struct weston_output *output)
> >  {
> > +       struct wl_resource *resource, *tmp;
> > +
> >         output->destroying = 1;
> >
> >         weston_compositor_remove_output(output->compositor, output);
> > @@ -3124,6 +3126,9 @@ weston_output_destroy(struct weston_output *output)
> >         output->compositor->output_id_pool &= ~(1 << output->id);
> >
> >         wl_global_destroy(output->global);
> > +
> > +       wl_resource_for_each_safe(resource, tmp, &output->resource_list)
> > +               wl_resource_destroy(resource);
> >  }
> >
> >  static void
> > --
> > 1.9.0
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140508/a771efb6/attachment.html>


More information about the wayland-devel mailing list