[Spice-devel] [spice-gtk 3/3] usb-device-manager: Fix USB event thread leak

Christophe Fergeau cfergeau at redhat.com
Thu Jun 30 13:49:51 UTC 2016


On Thu, Jun 30, 2016 at 01:49:57PM +0200, Hans de Goede wrote:
> Hi,
> Thinking about this more, the easiest fix is probably for
> channel-usbredir.c to take a ref on the usb_device_manager when it calls
> spice_usb_device_manager_start_event_listening(), and use that ref when
> it wants to call spice_usb_device_manager_stop_event_listening() and
> then g_clear_object its ref.

That's something I actually considered while looking at the issue, but
at the time I was not familiar with the code to be sure I would not
introduce cyclic references, and then I forgot. Now that you mention it,
this indeed should work (and I tested/sent patches doing that).

> Another potential issue I've noticed is the replacement of
> GSimpleAsyncResult with GTask, the code was relying on GSimpleAsyncResult
> taking a ref on the passed in gobject (the usbredir channel) and then
> releasing that after the callback has completed. I'm not sure if
> the GTask replacement code also does this, if not then we need to
> do this explicitly (in ALL places where we use GTask).

Yes, GTask takes a ref on its source object (first arg to g_task_new()).
This is what was causing problems in
https://cgit.freedesktop.org/spice/spice-gtk/commit/?id=183c84d07c62b6b0e9587208e5a8a0c808d72f32
I think. I also checked glib/gio/gtask.c to be 100% sure of this
statement.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160630/99588920/attachment.sig>


More information about the Spice-devel mailing list