Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sourceware.org
Cc: Aleksandar Ristovski <aristovski@qnx.com>
Subject: [PATCH] gdbserver: Reset current_thread when its process is removed.
Date: Thu, 15 Oct 2015 14:36:00 -0000	[thread overview]
Message-ID: <1444919808-22088-1-git-send-email-aristovski@qnx.com> (raw)

In case of running gdbserver with --multi, if a nat file
removes a process, current_thread may remain set to now
freed 'process' entry.

This may lead to wrong operation or a crash.

gdb/gdbserver/ChangeLog:
	* inferiors.c (remove_process): Reset current_thread if its
	associated process gets removed.
---
 gdb/gdbserver/inferiors.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 21f45fa..4688a44 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -291,6 +291,11 @@ remove_process (struct process_info *process)
 {
   clear_symbol_cache (&process->symbol_cache);
   free_all_breakpoints (process);
+  if (current_thread && get_thread_process (current_thread) == process)
+    {
+      remove_thread (current_thread);
+      current_thread = NULL;
+    }
   remove_inferior (&all_processes, &process->entry);
   free (process);
 }
-- 
1.9.1


             reply	other threads:[~2015-10-15 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-15 14:36 Aleksandar Ristovski [this message]
2015-10-15 16:22 ` Pedro Alves
2015-10-16 13:40   ` Aleksandar Ristovski
2015-10-16 14:04     ` Pedro Alves
2015-10-16 14:48       ` Aleksandar Ristovski
2015-10-16 15:06         ` Pedro Alves

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=1444919808-22088-1-git-send-email-aristovski@qnx.com \
    --to=aristovski@qnx.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