From 578755112a99655fdce6ed4ae924d82a31c26abb Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 31 Oct 2013 16:15:05 -0700 Subject: [PATCH] metrics: Fix to not try to call into OpenGL at atexit time. This could lead to all kinds of problems since the OpenGL call should be long-gone by the time of atexit. --- metrics.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/metrics.c b/metrics.c index 87da778..4e67ab9 100644 --- a/metrics.c +++ b/metrics.c @@ -865,14 +865,52 @@ print_program_metrics (void) free (sorted); } -/* Called at program exit */ +/* Called at program exit. + * + * This is similar to metrics_info_fini, but only frees any used + * memory. Notably, it does not call any OpenGL functions, (since the + * OpenGL context no longer exists at program exit). + */ static void metrics_exit (void) { + context_t *ctx = ¤t_context; + metrics_info_t *info = &ctx->metrics_info; + unsigned i; + timer_query_t *timer, *timer_next; + monitor_t *monitor, *monitor_next; + if (verbose) printf ("fips: terminating\n"); - metrics_info_fini (); + if (! info->initialized) + return; + + for (timer = ctx->timer_head; + timer; + timer = timer_next) + { + timer_next = timer->next; + free (timer); + } + + for (monitor = ctx->monitor_head; + monitor; + monitor = monitor_next) + { + monitor_next = monitor->next; + free (monitor); + } + + for (i = 0; i < info->num_groups; i++) + metrics_group_info_fini (&info->groups[i]); + + free (info->groups); + + for (i = 0; i < info->num_shader_stages; i++) + free (info->stages[i].name); + + free (info->stages); } void -- 2.43.0