Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [commit] Fix GDB crash (Re: [1/2] RFC: reference count breakpoint commands)
Date: Fri, 26 Mar 2010 16:43:00 -0000	[thread overview]
Message-ID: <201003261643.o2QGh7XD009247@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <m3zl1xh1h0.fsf@fleche.redhat.com> from "Tom Tromey" at Mar 24, 2010 03:08:27 PM

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


  reply	other threads:[~2010-03-26 16:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10  3:49 [1/2] RFC: reference count breakpoint commands Tom Tromey
2010-03-24 21:08 ` Tom Tromey
2010-03-26 16:43   ` Ulrich Weigand [this message]
2010-03-26 17:04     ` [commit] Fix GDB crash (Re: [1/2] RFC: reference count breakpoint commands) Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201003261643.o2QGh7XD009247@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox