profiler: Free ThreadInfo list on MetaProfiler finalize

This avoids use-after-free when handle_start() is called following
handle_stop() during the lifetime of the MetaProfiler. This happens
on repeated profiling sessions using Sysprof.

Fixes: e16d68372 ("profiler: Add API to register profiler threads")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3076>
This commit is contained in:
Dor Askayo 2023-06-14 18:48:36 +03:00
parent bc04fcb89d
commit f49b2a3c7d

View File

@ -193,7 +193,6 @@ handle_stop (MetaDBusSysprof3Profiler *dbus_profiler,
cogl_set_tracing_disabled_on_thread (thread_info->main_context); cogl_set_tracing_disabled_on_thread (thread_info->main_context);
} }
g_list_free_full (profiler->threads, (GDestroyNotify) thread_info_free);
g_mutex_unlock (&profiler->mutex); g_mutex_unlock (&profiler->mutex);
cogl_stop_tracing (); cogl_stop_tracing ();
@ -260,6 +259,7 @@ meta_profiler_finalize (GObject *object)
g_clear_object (&self->cancellable); g_clear_object (&self->cancellable);
g_clear_object (&self->connection); g_clear_object (&self->connection);
g_mutex_clear (&self->mutex); g_mutex_clear (&self->mutex);
g_list_free_full (self->threads, (GDestroyNotify) thread_info_free);
G_OBJECT_CLASS (meta_profiler_parent_class)->finalize (object); G_OBJECT_CLASS (meta_profiler_parent_class)->finalize (object);
} }