Also compare frame_id_is_next in frapy_richcompare

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.
This commit is contained in:
Hannes Domani
2020-12-18 18:23:41 +01:00
parent de8d420310
commit 83962f8340
2 changed files with 9 additions and 2 deletions

View File

@ -658,8 +658,11 @@ frapy_richcompare (PyObject *self, PyObject *other, int op)
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;