The last frame in a corrupt stack stores the frame_id of the next frame,
so these two frames currently compare as equal.
So if you have a backtrace where the oldest frame is corrupt, this happens:
(gdb) py
 >f = gdb.selected_frame()
 >while f.older():
 >  f = f.older()
 >print(f == f.newer())
 >end
True
With this change, that same example returns False.
gdb/ChangeLog:
2021-02-07  Hannes Domani  <ssbssa@yahoo.de>
	* python/py-frame.c (frapy_richcompare): Compare frame_id_is_next.
+2021-02-07  Hannes Domani  <ssbssa@yahoo.de>
+
+       * python/py-frame.c (frapy_richcompare): Compare frame_id_is_next.
+
 2021-02-05  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * symmisc.c (std_in, std_out, std_err): Remove.
 
       return Py_NotImplemented;
     }
 
-  if (frame_id_eq (((frame_object *) self)->frame_id,
-                  ((frame_object *) other)->frame_id))
+  frame_object *self_frame = (frame_object *) self;
+  frame_object *other_frame = (frame_object *) other;
+
+  if (self_frame->frame_id_is_next == other_frame->frame_id_is_next
+      && frame_id_eq (self_frame->frame_id, other_frame->frame_id))
     result = Py_EQ;
   else
     result = Py_NE;