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]

Re: [downstream patch FYI] workaround stale frame_info * (PR 13866)


On 04/04/2012 08:14 PM, Jan Kratochvil wrote:

> 
> Reproducer with:
> ./gdb -nx ~/t/thread -ex 'b 24' -ex r -ex 'until 25'
> Breakpoint 1, main () at /home/jkratoch/t/thread.c:24
> 24	  v++;
> Segmentation fault (core dumped)
> 
> #include <pthread.h>
> #include <assert.h>
> #include <unistd.h>
> 
> static int v;
> 
> static void *start (void *arg)
> {
>   v++;
>   v++;
>   v++;
>   v++;
>   sleep (100);
>   return arg;
> }
> 
> int main (void)
> {
>   pthread_t thread1;
>   int i;
> 
>   i = pthread_create (&thread1, NULL, start, NULL);
>   assert (i == 0);
>   v++;
>   v++;
>   v++;
>   v++;
>   i = pthread_join (thread1, NULL);
>   assert (i == 0);
> 
>   return 0;
> }


This fixes the crash.

2012-06-05  Pedro Alves  <palves@redhat.com>

	PR backtrace/13866

	* breakpoint.c (until_break_command): Only fetch the selected
	frame after decode_line_1.
---

 gdb/breakpoint.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5cc1f64..9757d0d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10815,10 +10815,10 @@ until_break_command (char *arg, int from_tty, int anywhere)
 {
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
-  struct frame_info *frame = get_selected_frame (NULL);
-  struct gdbarch *frame_gdbarch = get_frame_arch (frame);
-  struct frame_id stack_frame_id = get_stack_frame_id (frame);
-  struct frame_id caller_frame_id = frame_unwind_caller_id (frame);
+  struct frame_info *frame;
+  struct gdbarch *frame_gdbarch;
+  struct frame_id stack_frame_id;
+  struct frame_id caller_frame_id;
   struct breakpoint *breakpoint;
   struct breakpoint *breakpoint2 = NULL;
   struct cleanup *old_chain;
@@ -10854,6 +10854,11 @@ until_break_command (char *arg, int from_tty, int anywhere)

   old_chain = make_cleanup (null_cleanup, NULL);

+  frame = get_selected_frame (NULL);
+  frame_gdbarch = get_frame_arch (frame);
+  stack_frame_id = get_stack_frame_id (frame);
+  caller_frame_id = frame_unwind_caller_id (frame);
+
   /* Installing a breakpoint invalidates the frame chain (as it may
      need to switch threads), so do any frame handling first.  */


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