[PATCH 1/3] Add virtual destructor to dwarf2_per_cu_data

Tom Tromey tromey@adacore.com
Mon May 3 19:32:04 GMT 2021


Address sanitizer pointed out that the patch to use 'delete' for
dwarf2_per_cu_data introduced a bug -- now it is possible to delete a
signatured_type using a pointer to its base class.  This patch fixes
the problem by introducing a virtual destructor.

gdb/ChangeLog
2021-05-03  Tom Tromey  <tromey@adacore.com>

	* dwarf2/read.h (dwarf2_per_cu_data): Add virtual destructor.
---
 gdb/ChangeLog     | 4 ++++
 gdb/dwarf2/read.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 80f0e3ee13b..f514b8316ec 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -418,6 +418,8 @@ struct dwarf2_per_cu_data
   {
   }
 
+  virtual ~dwarf2_per_cu_data () = default;
+
   /* The start offset and length of this compilation unit.
      NOTE: Unlike comp_unit_head.length, this length includes
      initial_length_size.
-- 
2.26.3



More information about the Gdb-patches mailing list