* infrun.c (resume): If following a fork, reread the current
authorPedro Alves <palves@redhat.com>
Thu, 20 Nov 2008 13:23:26 +0000 (13:23 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 20 Nov 2008 13:23:26 +0000 (13:23 +0000)
thread.  Avoid dereferencing a possibly dangling pointer.

gdb/ChangeLog
gdb/infrun.c

index 4eabe76f4470331787b5a5a2e041295315f6414f..62b98fe5f993d210218bb1bb3c7fdd3d44358596 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-20  Pedro Alves  <pedro@codesourcery.com>
+
+       * infrun.c (resume): If following a fork, reread the current
+       thread.  Avoid dereferencing a possibly dangling pointer.
+
 2008-11-19  Doug Evans  <dje@google.com>
 
        * inferior.h (proceed_to_finish): Delete, unused.
index f218fa0e1f98d4bc1ea44261b932cdd56a730306..93ee00bc00a0050c550db8284e18c68dbce22623 100644 (file)
@@ -1053,6 +1053,10 @@ a command like `return' or `jump' to continue execution."));
       pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
       if (follow_fork ())
        should_resume = 0;
+
+      /* Following a child fork will change our notion of current
+        thread.  */
+      tp = inferior_thread ();
       break;
 
     case TARGET_WAITKIND_EXECD:
@@ -1148,11 +1152,11 @@ a command like `return' or `jump' to continue execution."));
           displaced_step_dump_bytes (gdb_stdlog, buf, sizeof (buf));
         }
 
-      target_resume (resume_ptid, step, sig);
-
       /* Avoid confusing the next resume, if the next stop/resume
         happens to apply to another thread.  */
       tp->stop_signal = TARGET_SIGNAL_0;
+
+      target_resume (resume_ptid, step, sig);
     }
 
   discard_cleanups (old_cleanups);