Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>,
	Joel Brobecker <brobecker@adacore.com>
Subject: [PATCH/7.6] Fix wrong release (maybe crash GDB) in build_target_command_list
Date: Wed, 24 Apr 2013 15:35:00 -0000	[thread overview]
Message-ID: <CANFwon0RCwi1CQepWnZuuPvXUNVHXJU-UbknXaR_U3h8shUc8g@mail.gmail.com> (raw)

Hi,

I found this bug when I try to fix 15180.
In function build_target_command_list:
When it try to release the loc->cmd_bytecode in the first loop, it try
to release loc->cond_bytecode:
  /* If anything failed, then we're not doing target-side commands,
     and so clean up.  */
  if (null_command_or_parse_error)
    {
      ALL_BP_LOCATIONS_AT_ADDR (loc2p, locp, bl->address)
	{
	  loc = (*loc2p);
	  if (is_breakpoint (loc->owner)
	      && loc->pspace->num == bl->pspace->num)
	    {
	      /* Only go as far as the first NULL bytecode is
		 located.  */
	      if (!loc->cond_bytecode)
		return;

	      free_agent_expr (loc->cond_bytecode);
	      loc->cond_bytecode = NULL;
	    }
	}
    }

I think it will crash GDB something.  So I suggest fix it before 7.6 release.

Thanks,
Hui

2013-04-24  Hui Zhu  <hui@codesourcery.com>

	* breakpoint.c (build_target_command_list): Change loc->cond_bytecode
	to loc->cmd_bytecode.

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2343,11 +2343,11 @@ build_target_command_list (struct bp_loc
 	    {
 	      /* Only go as far as the first NULL bytecode is
 		 located.  */
-	      if (!loc->cond_bytecode)
+	      if (!loc->cmd_bytecode)
 		return;

-	      free_agent_expr (loc->cond_bytecode);
-	      loc->cond_bytecode = NULL;
+	      free_agent_expr (loc->cmd_bytecode);
+	      loc->cmd_bytecode = NULL;
 	    }
 	}
     }


             reply	other threads:[~2013-04-24 13:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 15:35 Hui Zhu [this message]
2013-04-24 17:48 ` Tom Tromey
2013-04-24 19:13   ` Hui Zhu
2013-04-24 20:36     ` Tom Tromey
2013-04-25 12:49       ` Hui Zhu
2013-04-25 15:18         ` Joel Brobecker
2013-04-25 17:25           ` Hui Zhu
2013-04-24 18:58 ` Yao Qi

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=CANFwon0RCwi1CQepWnZuuPvXUNVHXJU-UbknXaR_U3h8shUc8g@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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