Because we LD_PRELOAD in front of the command line, which might contain gdb, the fini destructor in intel_dump_gpu.c might be called twice (once for the program we're tracing and once for gdb). This change prevents a crash in gdb when the aub->file has already been closed.
Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> --- src/intel/tools/aub_write.c | 5 ++++- src/intel/tools/intel_dump_gpu.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/intel/tools/aub_write.c b/src/intel/tools/aub_write.c index 6fb99feb005..c948a4852b0 100644 --- a/src/intel/tools/aub_write.c +++ b/src/intel/tools/aub_write.c @@ -286,7 +286,10 @@ void aub_file_finish(struct aub_file *aub) { aub_ppgtt_table_finish(&aub->pml4, 4); - fclose(aub->file); + if (aub->file) { + fclose(aub->file); + aub->file = NULL; + } } uint32_t diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c index 1abe54147cf..c4082c207f0 100644 --- a/src/intel/tools/intel_dump_gpu.c +++ b/src/intel/tools/intel_dump_gpu.c @@ -538,7 +538,13 @@ ioctl_init_helper(int fd, unsigned long request, ...) static void __attribute__ ((destructor)) fini(void) { - free(output_filename); aub_file_finish(&aub_file); - free(bos); + if (output_filename) { + free(output_filename); + output_filename = NULL; + } + if (bos) { + free(bos); + bos = NULL; + } } -- 2.18.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev