[v7,3/5] gdb/remote: do not delete a thread if it has a pending exit event

Message ID aed77a26d982e64c0389aba7690b70768cc4ecf1.1587563226.git.tankut.baris.aktemur@intel.com
State New
Headers show
Series
  • Untitled series #24757
Related show

Commit Message

Lancelot SIX via Gdb-patches April 22, 2020, 3 p.m.
gdb/ChangeLog:
2020-04-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* remote.c (remote_target::update_thread_list): Do not delete
	a thread if it has a pending exit event.
---
 gdb/remote.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.17.1

Comments

Lancelot SIX via Gdb-patches May 4, 2020, 2:43 p.m. | #1
Tankut,

I'm trying to get back to this, and I would like to apply the whole
series locally, but I'm afraid that I'm having trouble piecing the
series together.
Do you have a public branch where you have all the patches in the series
applied?  You could push it under users/ on sourceware.org for example.

Thanks,
Pedro Alves

On 4/22/20 4:00 PM, Tankut Baris Aktemur via Gdb-patches wrote:
> gdb/ChangeLog:

> 2020-04-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

> 

> 	* remote.c (remote_target::update_thread_list): Do not delete

> 	a thread if it has a pending exit event.

> ---

>  gdb/remote.c | 8 ++++++++

>  1 file changed, 8 insertions(+)

> 

> diff --git a/gdb/remote.c b/gdb/remote.c

> index 5db406e045c..a1fbaa02fb1 100644

> --- a/gdb/remote.c

> +++ b/gdb/remote.c

> @@ -3822,6 +3822,14 @@ remote_target::update_thread_list ()

>  	  if (tp->inf->process_target () != this)

>  	    continue;

>  

> +	  /* Do not remove the thread if it has a pending exit event.

> +	     Otherwise we may end up with a seemingly live inferior

> +	     (i.e.  pid != 0) that has no threads.  */

> +	  if (tp->suspend.waitstatus_pending_p

> +	      && (tp->suspend.waitstatus.kind == TARGET_WAITKIND_SIGNALLED

> +		  || tp->suspend.waitstatus.kind == TARGET_WAITKIND_EXITED))

> +	    continue;

> +

>  	  if (!context.contains_thread (tp->ptid))

>  	    {

>  	      /* Not found.  */

>
Lancelot SIX via Gdb-patches May 4, 2020, 3:33 p.m. | #2
On Monday, May 4, 2020 4:43 PM, Pedro Alves wrote:
> Tankut,

> 

> I'm trying to get back to this, and I would like to apply the whole

> series locally, but I'm afraid that I'm having trouble piecing the

> series together.

> Do you have a public branch where you have all the patches in the series

> applied?  You could push it under users/ on sourceware.org for example.

> 

> Thanks,

> Pedro Alves


Hi Pedro,

It's available at
https://github.com/barisaktemur/gdb/commits/thread-exit-in-stop-all-threads-v8

This branch also contains the two patches about enabling/disabling thread
events that I submitted yesterday:

https://sourceware.org/pipermail/gdb-patches/2020-May/168172.html
https://sourceware.org/pipermail/gdb-patches/2020-May/168173.html

Thanks.
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
Lancelot SIX via Gdb-patches May 13, 2020, 2:20 p.m. | #3
On 5/4/20 4:33 PM, Aktemur, Tankut Baris via Gdb-patches wrote:
> On Monday, May 4, 2020 4:43 PM, Pedro Alves wrote:

>> Tankut,

>>

>> I'm trying to get back to this, and I would like to apply the whole

>> series locally, but I'm afraid that I'm having trouble piecing the

>> series together.

>> Do you have a public branch where you have all the patches in the series

>> applied?  You could push it under users/ on sourceware.org for example.

>>

>> Thanks,

>> Pedro Alves

> 

> Hi Pedro,

> 

> It's available at

> https://github.com/barisaktemur/gdb/commits/thread-exit-in-stop-all-threads-v8


Thanks Tankut.  I've been playing with this.  I'm now convinced that the
approach to make sure that we don't delete the last thread is the best one.
I've been experimenting with it, and I think we're OK wrt the
TARGET_WAITKIND_NO_RESUMED code in infrun.c. I pointed at before.
I've poked at the multi-exit.exp testcase to make it spawn more than
two inferiors, to make sure we always hit the race window, even on slower
systems.  I'm now looking at multi-kill.exp.  I'll have something to
show soon.

Thanks,
Pedro Alves

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index 5db406e045c..a1fbaa02fb1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3822,6 +3822,14 @@  remote_target::update_thread_list ()
 	  if (tp->inf->process_target () != this)
 	    continue;
 
+	  /* Do not remove the thread if it has a pending exit event.
+	     Otherwise we may end up with a seemingly live inferior
+	     (i.e.  pid != 0) that has no threads.  */
+	  if (tp->suspend.waitstatus_pending_p
+	      && (tp->suspend.waitstatus.kind == TARGET_WAITKIND_SIGNALLED
+		  || tp->suspend.waitstatus.kind == TARGET_WAITKIND_EXITED))
+	    continue;
+
 	  if (!context.contains_thread (tp->ptid))
 	    {
 	      /* Not found.  */