Blame SOURCES/gdb-rhbz1225569-oom-killer-aarch64-frame-same-id-4of8.patch

7b26da
commit 6eeee81c8e59511962bdd83df5e7785bfdf871d2
7b26da
Author: Tom Tromey <tromey@redhat.com>
7b26da
Date:   Fri Nov 22 17:38:44 2013 +0000
7b26da
7b26da
    Detect infinite loop in value_fetch_lazy's lval_register handling.
7b26da
    
7b26da
    If value_fetch_lazy loops infinitely while unwrapping lval_register
7b26da
    values, it means we either somehow ended up with two frames with the
7b26da
    same ID in the frame chain, or some code is trying to unwind behind
7b26da
    get_prev_frame's back (e.g., a frame unwind sniffer trying to unwind).
7b26da
    In any case, it should always be an internal error to end up in this
7b26da
    situation.
7b26da
    
7b26da
    This patch adds a check and throws an internal error if the same frame
7b26da
    is returned.
7b26da
    
7b26da
    2013-11-22  Tom Tromey  <tromey@redhat.com>
7b26da
    	    Pedro Alves  <palves@redhat.com>
7b26da
    
7b26da
    	PR backtrace/16155
7b26da
    	* value.c (value_fetch_lazy): Internal error if
7b26da
    	get_frame_register_value returns the same register.
7b26da
7b26da
Index: gdb-7.6.1/gdb/valops.c
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/valops.c
7b26da
+++ gdb-7.6.1/gdb/valops.c
7b26da
@@ -1093,7 +1093,9 @@ value_fetch_lazy (struct value *val)
7b26da
 
7b26da
       while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
7b26da
 	{
7b26da
-	  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
7b26da
+	  struct frame_id frame_id = VALUE_FRAME_ID (new_val);
7b26da
+
7b26da
+	  frame = frame_find_by_id (frame_id);
7b26da
 	  regnum = VALUE_REGNUM (new_val);
7b26da
 
7b26da
 	  gdb_assert (frame != NULL);
7b26da
@@ -1107,6 +1109,22 @@ value_fetch_lazy (struct value *val)
7b26da
 						   regnum, type));
7b26da
 
7b26da
 	  new_val = get_frame_register_value (frame, regnum);
7b26da
+
7b26da
+	  /* If we get another lazy lval_register value, it means the
7b26da
+	     register is found by reading it from the next frame.
7b26da
+	     get_frame_register_value should never return a value with
7b26da
+	     the frame id pointing to FRAME.  If it does, it means we
7b26da
+	     either have two consecutive frames with the same frame id
7b26da
+	     in the frame chain, or some code is trying to unwind
7b26da
+	     behind get_prev_frame's back (e.g., a frame unwind
7b26da
+	     sniffer trying to unwind), bypassing its validations.  In
7b26da
+	     any case, it should always be an internal error to end up
7b26da
+	     in this situation.  */
7b26da
+	  if (VALUE_LVAL (new_val) == lval_register
7b26da
+	      && value_lazy (new_val)
7b26da
+	      && frame_id_eq (VALUE_FRAME_ID (new_val), frame_id))
7b26da
+	    internal_error (__FILE__, __LINE__,
7b26da
+			    _("infinite loop while fetching a register"));
7b26da
 	}
7b26da
 
7b26da
       /* If it's still lazy (for instance, a saved register on the