2008-11-20 Pedro Alves * infrun.c (resume): If following a fork, reread the current thread. Avoid dereferencing a possibly dangling pointer. --- gdb/infrun.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) Index: src/gdb/infrun.c =================================================================== --- src.orig/gdb/infrun.c 2008-11-20 05:37:35.000000000 +0000 +++ src/gdb/infrun.c 2008-11-20 12:30:26.000000000 +0000 @@ -1053,6 +1053,9 @@ a command like `return' or `jump' to con pending_follow.kind = TARGET_WAITKIND_SPURIOUS; if (follow_fork ()) should_resume = 0; + + /* Following a fork may change inferior_ptid. */ + tp = inferior_thread (); break; case TARGET_WAITKIND_EXECD: @@ -1148,11 +1151,11 @@ a command like `return' or `jump' to con 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);