This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] gdbserver: Reset current_thread when its process is removed.
- From: Aleksandar Ristovski <aristovski at qnx dot com>
- To: gdb-patches at sourceware dot org
- Cc: Aleksandar Ristovski <aristovski at qnx dot com>
- Date: Thu, 15 Oct 2015 10:36:48 -0400
- Subject: [PATCH] gdbserver: Reset current_thread when its process is removed.
- Authentication-results: sourceware.org; auth=none
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