Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Re: 3/5 - Rework stepping over longjmp support
Date: Mon, 05 May 2008 19:23:00 -0000	[thread overview]
Message-ID: <200805051750.33084.pedro@codesourcery.com> (raw)
In-Reply-To: <200805042049.44114.pedro@codesourcery.com>

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

A Sunday 04 May 2008 20:49:43, Pedro Alves wrote:
> A Friday 02 May 2008 15:38:22, Daniel Jacobowitz wrote:
> > On Fri, Apr 25, 2008 at 05:15:45PM +0100, Pedro Alves wrote:
> > > Still OK?  I'll check the new longjmp.exp test in along with this one.
> >
> > Looks fine to me.
>
> Thanks.  I've checked this one in, and the test too.
>
> Non-stop mode should be now safer regarding longjmp.

Except, it's crashing in async mode ...

thread_p was only allocated when (!single_inst || skip_subroutines),
because on the other cases, we don't need longjmp breakpoints,
but, it was always being dereferenced in async mode.

There's really no reason to be using the heap.  Fixed by moving
the variable to the stack (as cleanup memory is supposed to be
managed in the first place).

Checked in as obvious.

-- 
Pedro Alves

/me teaches himself to never do last minute changes.
-- 
Pedro Alves

[-- Attachment #2: fix_crash.diff --]
[-- Type: text/x-diff, Size: 1811 bytes --]

2008-05-05  Pedro Alves  <pedro@codesourcery.com>

	* infcmd.c (step_1): Put thread id on the stack to avoid possible
	NULL dereferencing.

---
 gdb/infcmd.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-05-05 17:33:46.000000000 +0100
+++ src/gdb/infcmd.c	2008-05-05 17:34:01.000000000 +0100
@@ -706,7 +706,7 @@ step_1 (int skip_subroutines, int single
   struct frame_info *frame;
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
   int async_exec = 0;
-  int *thread_p = NULL;
+  int thread = -1;
 
   ERROR_NO_INFERIOR;
 
@@ -730,17 +730,12 @@ step_1 (int skip_subroutines, int single
 
   if (!single_inst || skip_subroutines)		/* leave si command alone */
     {
-      thread_p = xmalloc (sizeof (int));
-      make_cleanup (xfree, thread_p);
-
       if (in_thread_list (inferior_ptid))
- 	*thread_p = pid_to_thread_id (inferior_ptid);
-      else
- 	*thread_p = -1;
+ 	thread = pid_to_thread_id (inferior_ptid);
 
       set_longjmp_breakpoint ();
 
-      make_cleanup (delete_longjmp_breakpoint_cleanup, thread_p);
+      make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
     }
 
   /* In synchronous case, all is well, just use the regular for loop. */
@@ -801,11 +796,10 @@ which has no line number information.\n"
      and handle them one at the time, through step_once(). */
   else
     {
-      step_once (skip_subroutines, single_inst, count, *thread_p);
+      step_once (skip_subroutines, single_inst, count, thread);
       /* We are running, and the continuation is installed.  It will
 	 disable the longjmp breakpoint as appropriate.  */
       discard_cleanups (cleanups);
-      xfree (thread_p);
     }
 }
 

      reply	other threads:[~2008-05-05 16:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07  2:34 Pedro Alves
2008-04-07 19:43 ` Tom Tromey
2008-04-14 18:57 ` Daniel Jacobowitz
2008-04-25 18:29   ` Pedro Alves
2008-05-02 14:41     ` Daniel Jacobowitz
2008-05-04 19:59       ` Pedro Alves
2008-05-05 19:23         ` Pedro Alves [this message]

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=200805051750.33084.pedro@codesourcery.com \
    --to=pedro@codesourcery.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