2017-12-10 22:00:49 +00:00
|
|
|
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
2017-12-04 19:24:00 +00:00
|
|
|
From: Fedora GDB patches <invalid@email.com>
|
|
|
|
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
2017-12-08 04:31:26 +00:00
|
|
|
Subject: workaround stale frame_info * (PR 13866)
|
2012-04-04 19:56:56 +00:00
|
|
|
|
2017-12-04 19:24:00 +00:00
|
|
|
FileName: gdb-stale-frame_info.patch
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
;; Workaround crashes from stale frame_info pointer (BZ 804256).
|
|
|
|
;;=push+jan
|
2017-12-04 19:24:00 +00:00
|
|
|
|
|
|
|
http://sourceware.org/ml/gdb-patches/2012-04/msg00058.html
|
|
|
|
|
2012-04-04 19:56:56 +00:00
|
|
|
Hi,
|
|
|
|
|
|
|
|
I did not look at which commit caused this regression but apparently it was
|
|
|
|
introduced at least with multi-inferiors.
|
|
|
|
|
|
|
|
I understand this fix is not right fix of the crash; but in most GDB cases one
|
|
|
|
does not use multi-inferior so why to regress single-inferior by it.
|
|
|
|
Some more simple solutions still fix the single-inferior mode but they
|
|
|
|
regressed the multi-inferior mode
|
|
|
|
gdb.threads/no-unwaited-for-left.exp
|
|
|
|
gdb.multi/base.exp
|
|
|
|
so I had to put there that sorting magic.
|
|
|
|
|
|
|
|
With proper C++ sanity check of stale live frame_info references the testcase
|
|
|
|
would be simple without the "frame_garbage_collection" reproducer below.
|
|
|
|
It is also reproducible just with valgrind but regularly running the whole
|
|
|
|
testsuite under valgrind I did not find feasible.
|
|
|
|
|
|
|
|
No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.
|
|
|
|
|
|
|
|
Thanks,
|
|
|
|
Jan
|
|
|
|
|
|
|
|
gdb/
|
|
|
|
2012-04-04 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
|
|
|
|
Workaround PR backtrace/13866.
|
|
|
|
* progspace.c (switch_to_program_space_and_thread): Try not to call
|
|
|
|
switch_to_thread.
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
diff --git a/gdb/progspace-and-thread.c b/gdb/progspace-and-thread.c
|
|
|
|
--- a/gdb/progspace-and-thread.c
|
|
|
|
+++ b/gdb/progspace-and-thread.c
|
|
|
|
@@ -23,15 +23,29 @@
|
2012-04-04 19:56:56 +00:00
|
|
|
void
|
2017-12-08 04:31:26 +00:00
|
|
|
switch_to_program_space_and_thread (program_space *pspace)
|
2012-04-04 19:56:56 +00:00
|
|
|
{
|
2017-12-08 04:31:26 +00:00
|
|
|
- inferior *inf = find_inferior_for_program_space (pspace);
|
|
|
|
+ inferior *inf = current_inferior ();
|
|
|
|
+
|
2012-04-04 19:56:56 +00:00
|
|
|
+ if (inf->pspace != pspace)
|
|
|
|
+ inf = find_inferior_for_program_space (pspace);
|
2017-12-08 04:31:26 +00:00
|
|
|
|
2015-01-08 20:53:17 +00:00
|
|
|
if (inf != NULL && inf->pid != 0)
|
2012-04-04 19:56:56 +00:00
|
|
|
{
|
2017-12-08 04:31:26 +00:00
|
|
|
thread_info *tp = any_live_thread_of_process (inf->pid);
|
|
|
|
+ thread_info *current_tp = NULL;
|
2012-04-04 19:56:56 +00:00
|
|
|
+
|
|
|
|
+ if (ptid_get_pid (inferior_ptid) == inf->pid)
|
|
|
|
+ current_tp = find_thread_ptid (inferior_ptid);
|
|
|
|
|
|
|
|
if (tp != NULL)
|
|
|
|
{
|
|
|
|
- switch_to_thread (tp->ptid);
|
|
|
|
+ /* Prefer primarily thread not THREAD_EXITED and secondarily thread
|
|
|
|
+ not EXECUTING. */
|
|
|
|
+ if (current_tp == NULL
|
|
|
|
+ || (tp->state != THREAD_EXITED
|
|
|
|
+ && current_tp->state == THREAD_EXITED)
|
|
|
|
+ || (!tp->executing && current_tp->executing))
|
|
|
|
+ switch_to_thread (tp->ptid);
|
|
|
|
+
|
|
|
|
/* Switching thread switches pspace implicitly. We're
|
|
|
|
done. */
|
|
|
|
return;
|