Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix double free on error while inserting the breakpoint
@ 2008-11-24  3:35 Jan Kratochvil
  2009-04-22 23:11 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2008-11-24  3:35 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

Hi,

SEGV reproducer:

x86 requires to build GDB with -lmcheck to make the crash reproducible.
Therefore no testsuite testcase is provided.
./gdb -nx -ex start -ex 'set breakpoint always-inserted on' -ex 'b *0' -ex 'delete 2' ./gdb

(Found on ia64 without -lmcheck.)


Regards,
Jan

[-- Attachment #2: gdb-breakpoint-free.patch --]
[-- Type: text/plain, Size: 1340 bytes --]

2008-11-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix double free on error inserting the breakpoint instruction.
	* breakpoint.c (create_breakpoints): Move the
	update_global_location_list call to ...
	(break_command_really): ... here together with the second local call
	both unified after all the cleanups.

--- gdb/breakpoint.c	22 Nov 2008 04:41:45 -0000	1.362
+++ gdb/breakpoint.c	22 Nov 2008 20:10:07 -0000
@@ -5257,8 +5257,6 @@ create_breakpoints (struct symtabs_and_l
 			 cond_string, type, disposition,
 			 thread, ignore_count, ops, from_tty);
     }
-
-  update_global_location_list (1);
 }
 
 /* Parse ARG which is assumed to be a SAL specification possibly
@@ -5579,7 +5577,6 @@ break_command_really (char *arg, char *c
       b->condition_not_parsed = 1;
       b->ops = ops;
 
-      update_global_location_list (1);
       mention (b);
     }
   
@@ -5591,6 +5588,11 @@ break_command_really (char *arg, char *c
   discard_cleanups (breakpoint_chain);
   /* But cleanup everything else. */
   do_cleanups (old_chain);
+
+  /* Have already BREAKPOINT_CHAIN discarded as we may get an exception while
+     inserting the breakpoints which would double-free the resources both by
+     BREAKPOINT_CHAIN now and during DELETE_BREAKPOINT in the future.  */
+  update_global_location_list (1);
 }
 
 /* Set a breakpoint. 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-04-23 22:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-24  3:35 [patch] Fix double free on error while inserting the breakpoint Jan Kratochvil
2009-04-22 23:11 ` Tom Tromey
2009-04-23 20:36   ` Jan Kratochvil
2009-04-23 21:25     ` Tom Tromey
2009-04-23 22:40       ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox