Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix linux-nat.c new_lp dropped status
@ 2010-07-18 22:09 Jan Kratochvil
  2010-07-20 12:46 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-07-18 22:09 UTC (permalink / raw)
  To: gdb-patches

Hi,

while reading the code it seems to me it can drop non-SIGSTOP status in this
case.  It can happen only during some racy case while creating a thread,
I have not tried to exploit it.

Does the patch make sense?  I have no dependency on it, I just have seen it.

No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.


Thanks,
Jan


--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -2288,6 +2288,23 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
 	      linux_ops->to_resume (linux_ops, pid_to_ptid (new_pid),
 				    0, signo);
 	    }
+	  else
+	    {
+	      if (status != 0)
+		{
+		  /* We created NEW_LP so it cannot yet contain STATUS.  */
+		  gdb_assert (new_lp->status == 0);
+
+		  /* Save the wait status to report later.  */
+		  if (debug_linux_nat)
+		    fprintf_unfiltered (gdb_stdlog,
+					"LHEW: waitpid of new LWP %ld, "
+					"saving status %s\n",
+					(long) GET_LWP (new_lp->ptid),
+					status_to_str (status));
+		  new_lp->status = status;
+		}
+	    }
 
 	  if (debug_linux_nat)
 	    fprintf_unfiltered (gdb_stdlog,


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

* Re: [patch] Fix linux-nat.c new_lp dropped status
  2010-07-18 22:09 [patch] Fix linux-nat.c new_lp dropped status Jan Kratochvil
@ 2010-07-20 12:46 ` Pedro Alves
  2010-07-20 12:56   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2010-07-20 12:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil

On Sunday 18 July 2010 23:08:53, Jan Kratochvil wrote:
> Hi,
> 
> while reading the code it seems to me it can drop non-SIGSTOP status in this
> case.  It can happen only during some racy case while creating a thread,
> I have not tried to exploit it.
> 
> Does the patch make sense?  I have no dependency on it, I just have seen it.

It does to me.  Okay, thanks.

> 
> No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
> 
> 
> Thanks,
> Jan
> 
> 
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -2288,6 +2288,23 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
>  	      linux_ops->to_resume (linux_ops, pid_to_ptid (new_pid),
>  				    0, signo);
>  	    }
> +	  else
> +	    {
> +	      if (status != 0)
> +		{
> +		  /* We created NEW_LP so it cannot yet contain STATUS.  */
> +		  gdb_assert (new_lp->status == 0);
> +
> +		  /* Save the wait status to report later.  */
> +		  if (debug_linux_nat)
> +		    fprintf_unfiltered (gdb_stdlog,
> +					"LHEW: waitpid of new LWP %ld, "
> +					"saving status %s\n",
> +					(long) GET_LWP (new_lp->ptid),
> +					status_to_str (status));
> +		  new_lp->status = status;
> +		}
> +	    }
>  
>  	  if (debug_linux_nat)
>  	    fprintf_unfiltered (gdb_stdlog,
> 


-- 
Pedro Alves


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

* Re: [patch] Fix linux-nat.c new_lp dropped status
  2010-07-20 12:46 ` Pedro Alves
@ 2010-07-20 12:56   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-07-20 12:56 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Tue, 20 Jul 2010 14:46:20 +0200, Pedro Alves wrote:
> On Sunday 18 July 2010 23:08:53, Jan Kratochvil wrote:
> It does to me.  Okay, thanks.

Checked-in, with a forgotten ChangeLog entry this time.


> > No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
                                                     ^^=13 in my recent mails.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2010-07/msg00113.html

--- src/gdb/ChangeLog	2010/07/20 12:33:29	1.12001
+++ src/gdb/ChangeLog	2010/07/20 12:54:57	1.12002
@@ -1,5 +1,10 @@
 2010-07-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	* linux-nat.c (linux_handle_extended_wait): Handle case when
+	event == PTRACE_EVENT_CLONE && stopping && WSTOPSIG (status) != SIGSTOP.
+
+2010-07-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	Code cleanup.
 	* linux-nat.c (linux_nat_wait_1): Reset STATUS after calling
 	linux_nat_wait_1.  Use always LP->STATUS afterwards.
--- src/gdb/linux-nat.c	2010/07/20 12:33:30	1.175
+++ src/gdb/linux-nat.c	2010/07/20 12:54:57	1.176
@@ -2279,6 +2279,23 @@
 	      linux_ops->to_resume (linux_ops, pid_to_ptid (new_pid),
 				    0, signo);
 	    }
+	  else
+	    {
+	      if (status != 0)
+		{
+		  /* We created NEW_LP so it cannot yet contain STATUS.  */
+		  gdb_assert (new_lp->status == 0);
+
+		  /* Save the wait status to report later.  */
+		  if (debug_linux_nat)
+		    fprintf_unfiltered (gdb_stdlog,
+					"LHEW: waitpid of new LWP %ld, "
+					"saving status %s\n",
+					(long) GET_LWP (new_lp->ptid),
+					status_to_str (status));
+		  new_lp->status = status;
+		}
+	    }
 
 	  if (debug_linux_nat)
 	    fprintf_unfiltered (gdb_stdlog,


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

end of thread, other threads:[~2010-07-20 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-18 22:09 [patch] Fix linux-nat.c new_lp dropped status Jan Kratochvil
2010-07-20 12:46 ` Pedro Alves
2010-07-20 12:56   ` Jan Kratochvil

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