This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ob] fix crash after failing to restore the selected frame


My recent changes for the non-stop mode, introduced a possible segv.

Although it should now be very rare to fail to restore the selected
frame if the frame layout didn't really change, I happened to
be working on something and introduced a bug which then triggered
this to happen.

If we failed to find the previously selected frame, we'd get
frame == NULL, and passing that to print_stack_frame would
end up dereferencing it.

The attached patch fixes it.

Checked in as obvious.

-- 
Pedro Alves
2008-07-13  Pedro Alves  <pedro@codesourcery.com>

	* thread.c (restore_selected_frame): On fail to restore, select
	the innermost frame, and don't crash when warning the user.

---
 gdb/thread.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2008-07-13 20:01:43.000000000 +0100
+++ src/gdb/thread.c	2008-07-13 20:06:39.000000000 +0100
@@ -938,8 +938,11 @@ restore_selected_frame (struct frame_id 
       return;
     }
 
-  /* Nothing else to do, the frame layout really changed.
-     Tell the user.  */
+  /* Nothing else to do, the frame layout really changed.  Select the
+     innermost stack frame.  */
+  select_frame (get_current_frame ());
+
+  /* Warn the user.  */
   if (!ui_out_is_mi_like_p (uiout))
     {
       warning (_("\
@@ -948,7 +951,7 @@ Couldn't restore frame #%d in current th
       /* For MI, we should probably have a notification about
 	 current frame change.  But this error is not very
 	 likely, so don't bother for now.  */
-      print_stack_frame (frame, 1, SRC_LINE);
+      print_stack_frame (get_selected_frame (NULL), 1, SRC_LINE);
     }
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]