util: Shut down Perfetto before driver unload

Shut down Perfetto before unloading the driver to fix a crash caused by
an internal Perfetto thread that kept running after dlclose() took away
its code.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4909
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17454>
This commit is contained in:
Sami Kyöstilä 2022-07-11 16:36:31 +10:00 committed by Marge Bot
parent 1a07a07a50
commit 0ff4f5a7e9
1 changed files with 7 additions and 0 deletions

View File

@ -27,6 +27,12 @@
#include "u_perfetto.h"
static void
util_perfetto_fini(void)
{
perfetto::Tracing::Shutdown();
}
static void
util_perfetto_init_once(void)
{
@ -34,6 +40,7 @@ util_perfetto_init_once(void)
perfetto::TracingInitArgs args;
args.backends = perfetto::kSystemBackend;
perfetto::Tracing::Initialize(args);
atexit(&util_perfetto_fini);
}
static once_flag perfetto_once_flag = ONCE_FLAG_INIT;