This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Fix GDB crash (Re: [1/2] RFC: reference count breakpoint commands)
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: tromey at redhat dot com
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 26 Mar 2010 17:43:07 +0100 (CET)
- Subject: [commit] Fix GDB crash (Re: [1/2] RFC: reference count breakpoint commands)
Tom Tromey wrote:
> 2010-03-24 Tom Tromey <tromey@redhat.com>
>
> * breakpoint.h (struct counted_command_line): New struct.
> (struct breakpoint) <commands>: Change type.
> (struct bpstats) <commands>: Change type.
> <commands_left>: New field.
> * breakpoint.c (alloc_counted_command_line): New function.
> (incref_counted_command_line): Likewise.
> (decref_counted_command_line): Likewise.
> (do_cleanup_counted_command_line): Likewise.
> (make_cleanup_decref_counted_command_line): Likewise.
> (breakpoint_set_commands): Use decref_counted_command_line and
> alloc_counted_command_line.
> (commands_command): Don't error if breakpoint commands are
> executing.
> (commands_from_control_command): Likewise.
> (bpstat_free): Update.
> (bpstat_copy): Likewise.
> (bpstat_clear_actions): Likewise.
> (bpstat_do_actions_1): Likewise.
> (bpstat_stop_status): Likewise.
> (print_one_breakpoint_location): Likewise.
> (delete_breakpoint): Likewise.
> (bpstat_alloc): Initialize new field.
> (tracepoint_save_command): Update.
> * tracepoint.c (encode_actions): Update.
> (trace_dump_command): Update.
This patch caused GDB to crash for me during execution of the commands.exp
test case. The problem appears to be caused by a bpstat with NULL commands,
but a non-NULL commands_left pointing to uninitialized memory.
By inspection, it looks like there is one place (bpstat_clear_actions) where
commands is cleared, but commands_left is left unchanged. It seems that
commands_left ought to be cleared there as well.
The following patch implements this, fixing the crash I was seeing.
Tested on powerpc64-linux, committed to mainline.
Bye,
Ulrich
ChangeLog:
* breakpoint.c (bpstat_clear_actions): Reset bs->commands_left.
Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.468
diff -u -p -r1.468 breakpoint.c
--- gdb/breakpoint.c 25 Mar 2010 20:48:52 -0000 1.468
+++ gdb/breakpoint.c 26 Mar 2010 16:04:42 -0000
@@ -2986,6 +2986,7 @@ bpstat_clear_actions (bpstat bs)
for (; bs != NULL; bs = bs->next)
{
decref_counted_command_line (&bs->commands);
+ bs->commands_left = NULL;
if (bs->old_val != NULL)
{
value_free (bs->old_val);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com