This is the mail archive of the 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: [PATCH] Don't let two frames with the same id end up in the frame chain. (Re: [PATCH 1/2] avoid infinite loop with bad debuginfo)

>>>>> "Pedro" == Pedro Alves <> writes:

Tom> Really not looking forward to writing the test.

Pedro> Yeah, me neither. :-P

Well, I took at stab at it today, and totally failed.
I will try to catch you on irc tomorrow to pick your brain, if that's ok
with you, to try to understand how I could get a test case.

Pedro> Subject: Don't let two frames with the same id end up in the frame chain.

Pedro> The UNWIND_SAME_ID check is done between THIS_FRAME and the next
Pedro> frame.  But at this point, it's already too late -- we ended up with
Pedro> two frames with the same ID in the frame chain.  Each frame having its
Pedro> own ID is an invariant assumed throughout GDB.  So this patch applies
Pedro> the UNWIND_SAME_ID detection earlier, right after the previous frame
Pedro> is unwond, discarding the dup frame if a cycle is detected.


FWIW I have nearly the identical patch here :)
I think it's a good idea.

I also have the appended, which makes the frame stash behave a little
nicer if an unwinder gives a duplicate frame id.  Probably not needed in
addition to the patch you sent, but on the other hand, cheap.


diff --git a/gdb/frame.c b/gdb/frame.c
index 63f20d5..dd419c9 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -203,7 +203,13 @@ frame_stash_add (struct frame_info *frame)
       slot = (struct frame_info **) htab_find_slot (frame_stash,
-      *slot = frame;
+      /* While it is invalid for two frames to have the same ID, it
+	 may happen due to a bug elsewhere in gdb.  And, should this
+	 happen, it is better for the frame stash to return the newer
+	 frame.  So, ignore duplicates here.  */
+      if (*slot == NULL)
+	*slot = frame;

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