This is the mail archive of the
mailing list for the GDB project.
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)
- From: Tom Tromey <tromey at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 20 Nov 2013 14:21:27 -0700
- Subject: 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)
- Authentication-results: sourceware.org; auth=none
- References: <1384375873-32160-1-git-send-email-tromey at redhat dot com> <1384375873-32160-2-git-send-email-tromey at redhat dot com> <52850730 dot 1060109 at redhat dot com> <87d2lxpo1l dot fsf at fleche dot redhat dot com> <528B7F15 dot 7040605 at redhat dot com> <87vbzomm78 dot fsf at fleche dot redhat dot com> <528B8FF6 dot 7000406 at redhat dot com> <87siusl10r dot fsf at fleche dot redhat dot com> <528BB700 dot 4000802 at redhat dot com> <87fvqskumd dot fsf at fleche dot redhat dot com> <528CFEDE dot 1040505 at redhat dot com>
>>>>> "Pedro" == Pedro Alves <firstname.lastname@example.org> 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
@@ -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;