public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Fix leaks by clearing registers and frame caches.
@ 2019-05-04  5:49 Philippe Waroquiers
  0 siblings, 0 replies; only message in thread
From: Philippe Waroquiers @ 2019-05-04  5:49 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=66452beb773568c7f60dbc6b7c70f671a8c9cf4b

commit 66452beb773568c7f60dbc6b7c70f671a8c9cf4b
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Tue Apr 30 22:18:48 2019 +0200

    Fix leaks by clearing registers and frame caches.
    
    Valgrind reports leaks such as the below in the tests:
    gdb.threads/corethreads.exp
    gdb.threads/gcore-thread.exp
    gdb.ada/task_switch_in_core.exp
    gdb.trace/tfile.exp
    gdb.base/siginfo-thread.exp
    
    ==12701== 1,123 (72 direct, 1,051 indirect) bytes in 1 blocks are definitely lost in loss record 2,928 of 3,247
    ==12701==    at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344)
    ==12701==    by 0x5CF771: get_thread_arch_aspace_regcache(ptid_t, gdbarch*, address_space*) (regcache.c:330)
    ==12701==    by 0x5CF92A: get_thread_regcache (regcache.c:366)
    ==12701==    by 0x5CF92A: get_current_regcache() (regcache.c:372)
    ==12701==    by 0x4C7964: get_current_frame() (frame.c:1587)
    ==12701==    by 0x4C7A3C: get_selected_frame(char const*) (frame.c:1651)
    ==12701==    by 0x669EAD: print_thread_info_1(ui_out*, char const*, int, int, int) (thread.c:1151)
    ==12701==    by 0x66A9A1: info_threads_command(char const*, int) (thread.c:1217)
    ==12701==    by 0x40A878: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1892)
    ...
    
    Fix these leaks by clearing registers and frame caches.
    This leak and fix is similar to the leak fixed by 799efbe8e01

Diff:
---
 gdb/ChangeLog  | 6 ++++++
 gdb/corelow.c  | 2 ++
 gdb/inferior.c | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b4e3a55..0b8d562 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-04  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+	* corelow.c (core_target::detach): Ensure frame cache and
+	register caches are cleared.
+	inferior.c (exit_inferior_1): Likewise.
+
 2019-05-03  Sandra Loosemore  <sandra@codesourcery.com>
 	    Tom Tromey  <tom@tromey.com>
 
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 3ce612d..9fcc2d2 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -535,6 +535,8 @@ core_target::detach (inferior *inf, int from_tty)
      'this'.  */
   unpush_target (this);
 
+  /* Clear the register cache and the frame cache.  */
+  registers_changed ();
   reinit_frame_cache ();
   maybe_say_no_core_file_now (from_tty);
 }
diff --git a/gdb/inferior.c b/gdb/inferior.c
index e7b4937..abfef70 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -208,6 +208,10 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
   inf->pending_detach = 0;
   /* Reset it.  */
   inf->control = inferior_control_state (NO_STOP_QUIETLY);
+
+  /* Clear the register cache and the frame cache.  */
+  registers_changed ();
+  reinit_frame_cache ();
 }
 
 void


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-04  5:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-04  5:49 [binutils-gdb] Fix leaks by clearing registers and frame caches Philippe Waroquiers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).