]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Fix use-after-free when destroying objfile
authorTom Tromey <tom@tromey.com>
Tue, 14 Oct 2025 03:36:56 +0000 (21:36 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 14 Oct 2025 03:40:19 +0000 (21:40 -0600)
commit4109b068142bc8e7c19728c163c5685fdaeea851
treed114d10337209563afa3916b8d0fe88aec8e143d
parent2358bcf0459f7f6d49622e8ad0bfbb9a2bb10b5f
Fix use-after-free when destroying objfile

The recent patch to heap-allocate compunit_symtabs introduced a
use-after-free that can occur when destroying an objfile.  The bug
here is that the objfile obstack is destroyed before compunit_symtabs;
but the compunit_symtabs destructor refers to the symtabs, which are
allocated on the obstack.

This patch fixes the problem.  This was reported using ASAN, but I
reproduced it with valgrind and verified that this fixes the problem.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33435
gdb/objfiles.h
gdb/symfile.c