Philippe Waroquiers
2018-11-04 20:39:49 UTC
Valgrind reports a definite leak of displaced->step_saved_copy
(full leak stack trace below).
This patch fixes the leak by calling xfree (displaced->step_saved_copy)
in displaced_step_clear.
==4736== VALGRIND_GDB_ERROR_BEGIN
==4736== 128 bytes in 8 blocks are definitely lost in loss record 980 of 3,108
==4736== at 0x4C2BE2D: malloc (vg_replace_malloc.c:299)
==4736== by 0x41B627: xmalloc (common-utils.c:44)
==4736== by 0x50D4E3: displaced_step_prepare_throw (infrun.c:1837)
==4736== by 0x50D4E3: displaced_step_prepare (infrun.c:1898)
==4736== by 0x50D4E3: resume_1 (infrun.c:2545)
==4736== by 0x50D4E3: resume(gdb_signal) (infrun.c:2741)
==4736== by 0x50DCD5: keep_going_pass_signal(execution_control_state*) (infrun.c:7793)
==4736== by 0x50E903: process_event_stop_test(execution_control_state*) (infrun.c:6843)
==4736== by 0x510925: handle_signal_stop(execution_control_state*) (infrun.c:6176)
==4736== by 0x513F79: handle_inferior_event_1 (infrun.c:5354)
==4736== by 0x513F79: handle_inferior_event(execution_control_state*) (infrun.c:5389)
==4736== by 0x51541B: fetch_inferior_event(void*) (infrun.c:3916)
==4736== by 0x4B3EEC: gdb_wait_for_event(int) (event-loop.c:859)
==4736== by 0x4B3FF6: gdb_do_one_event() [clone .part.4] (event-loop.c:322)
==4736== by 0x4B41B4: gdb_do_one_event (common-exceptions.h:219)
==4736== by 0x4B41B4: start_event_loop() (event-loop.c:371)
==4736== by 0x551237: captured_command_loop() (main.c:330)
==4736== by 0x55222C: captured_main (main.c:1177)
==4736== by 0x55222C: gdb_main(captured_main_args*) (main.c:1193)
==4736== by 0x29B4F7: main (gdb.c:32)
==4736==
==4736== VALGRIND_GDB_ERROR_END
gdb/ChangeLog
2018-11-04 Philippe Waroquiers <***@skynet.be>
* infrun.c (displaced_step_clear): Fix leak by xfree-ing
displaced->step_saved_copy.
---
gdb/infrun.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9473d1f20f..526ad2acb1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1709,6 +1709,12 @@ displaced_step_clear (struct displaced_step_inferior_state *displaced)
delete displaced->step_closure;
displaced->step_closure = NULL;
+
+ if (displaced->step_saved_copy != NULL)
+ {
+ xfree (displaced->step_saved_copy);
+ displaced->step_saved_copy = NULL;
+ }
}
static void
(full leak stack trace below).
This patch fixes the leak by calling xfree (displaced->step_saved_copy)
in displaced_step_clear.
==4736== VALGRIND_GDB_ERROR_BEGIN
==4736== 128 bytes in 8 blocks are definitely lost in loss record 980 of 3,108
==4736== at 0x4C2BE2D: malloc (vg_replace_malloc.c:299)
==4736== by 0x41B627: xmalloc (common-utils.c:44)
==4736== by 0x50D4E3: displaced_step_prepare_throw (infrun.c:1837)
==4736== by 0x50D4E3: displaced_step_prepare (infrun.c:1898)
==4736== by 0x50D4E3: resume_1 (infrun.c:2545)
==4736== by 0x50D4E3: resume(gdb_signal) (infrun.c:2741)
==4736== by 0x50DCD5: keep_going_pass_signal(execution_control_state*) (infrun.c:7793)
==4736== by 0x50E903: process_event_stop_test(execution_control_state*) (infrun.c:6843)
==4736== by 0x510925: handle_signal_stop(execution_control_state*) (infrun.c:6176)
==4736== by 0x513F79: handle_inferior_event_1 (infrun.c:5354)
==4736== by 0x513F79: handle_inferior_event(execution_control_state*) (infrun.c:5389)
==4736== by 0x51541B: fetch_inferior_event(void*) (infrun.c:3916)
==4736== by 0x4B3EEC: gdb_wait_for_event(int) (event-loop.c:859)
==4736== by 0x4B3FF6: gdb_do_one_event() [clone .part.4] (event-loop.c:322)
==4736== by 0x4B41B4: gdb_do_one_event (common-exceptions.h:219)
==4736== by 0x4B41B4: start_event_loop() (event-loop.c:371)
==4736== by 0x551237: captured_command_loop() (main.c:330)
==4736== by 0x55222C: captured_main (main.c:1177)
==4736== by 0x55222C: gdb_main(captured_main_args*) (main.c:1193)
==4736== by 0x29B4F7: main (gdb.c:32)
==4736==
==4736== VALGRIND_GDB_ERROR_END
gdb/ChangeLog
2018-11-04 Philippe Waroquiers <***@skynet.be>
* infrun.c (displaced_step_clear): Fix leak by xfree-ing
displaced->step_saved_copy.
---
gdb/infrun.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9473d1f20f..526ad2acb1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1709,6 +1709,12 @@ displaced_step_clear (struct displaced_step_inferior_state *displaced)
delete displaced->step_closure;
displaced->step_closure = NULL;
+
+ if (displaced->step_saved_copy != NULL)
+ {
+ xfree (displaced->step_saved_copy);
+ displaced->step_saved_copy = NULL;
+ }
}
static void
--
2.19.1
2.19.1