From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] avoid infinite loop with bad debuginfo
Date: Fri, 22 Nov 2013 14:52:00 -0000 [thread overview]
Message-ID: <528F6AC0.6020509@redhat.com> (raw)
In-Reply-To: <87d2lxpo1l.fsf@fleche.redhat.com>
On 11/18/2013 06:23 PM, Tom Tromey wrote:
>>> + if (VALUE_LVAL (new_val) == lval_register
>>> + && value_lazy (new_val)
>>> + && frame_id_eq (VALUE_FRAME_ID (new_val), last_frame_id))
>
> Pedro> I think this should also check the regnum:
>
> Barf. I have a memory of actually writing that. False memory I guess.
> Sigh.
Don't sigh. :-) I now believe the regnum check would be wrong.
This shouldn't return any register of the same frame.
WDYT of adjusting the patch like this?
------
From: Tom Tromey <tromey@redhat.com>
Subject: [PATCH] Detect lval_register handling infinite loop in
value_fetch_lazy.
If value_fetch_lazy loops infinitely while unwrapping lval_register
values, it means we either somehow ended up with two frames with the
same ID in the frame chain, or some code is trying to unwind behind
get_prev_frame's back (e.g., a frame unwind sniffer trying to unwind).
In any case, it should always be an internal error to end up in this
situation.
This patch adds a check and throws an internal error if the same frame
is returned.
2013-11-22 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
PR backtrace/16155
* value.c (value_fetch_lazy): Internal error if
get_frame_register_value returns the same register.
---
gdb/value.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/gdb/value.c b/gdb/value.c
index 8c263ea..da7778f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3507,7 +3507,9 @@ value_fetch_lazy (struct value *val)
while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
- frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
+ struct frame_id frame_id = VALUE_FRAME_ID (new_val);
+
+ frame = frame_find_by_id (frame_id);
regnum = VALUE_REGNUM (new_val);
gdb_assert (frame != NULL);
@@ -3521,6 +3523,22 @@ value_fetch_lazy (struct value *val)
regnum, type));
new_val = get_frame_register_value (frame, regnum);
+
+ /* If we get another lazy lval_register value, it means the
+ register is found by reading it from the next frame.
+ get_frame_register_value should never return a value with
+ the frame id pointing to FRAME. If it does, it means we
+ either have two consecutive frames with the same frame id
+ in the frame chain, or some code is trying to unwind
+ behind get_prev_frame's back (e.g., a frame unwind
+ sniffer trying to unwind), bypassing its validations. In
+ any case, it should always be an internal error to end up
+ in this situation. */
+ if (VALUE_LVAL (new_val) == lval_register
+ && value_lazy (new_val)
+ && frame_id_eq (VALUE_FRAME_ID (new_val), frame_id))
+ internal_error (__FILE__, __LINE__,
+ _("infinite loop while fetching a register"));
}
/* If it's still lazy (for instance, a saved register on the
--
1.7.11.7
next prev parent reply other threads:[~2013-11-22 14:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 20:51 [PATCH 0/2] fix multi-threaded unwinding on AArch64 Tom Tromey
2013-11-13 20:51 ` [PATCH 2/2] handle an unspecified return address column Tom Tromey
2013-11-22 18:22 ` Tom Tromey
2013-11-26 13:55 ` Joel Brobecker
2013-11-26 14:30 ` Mark Kettenis
2013-11-26 14:37 ` Joel Brobecker
2013-11-26 14:41 ` Mark Kettenis
2013-11-26 14:42 ` Joel Brobecker
2013-11-26 14:50 ` Tom Tromey
2013-11-26 15:05 ` Tom Tromey
2013-11-26 15:16 ` Tom Tromey
2013-11-26 16:11 ` Joel Brobecker
2013-11-13 22:03 ` [PATCH 1/2] avoid infinite loop with bad debuginfo Tom Tromey
2013-11-14 17:34 ` Pedro Alves
2013-11-18 18:25 ` Tom Tromey
2013-11-19 15:10 ` Pedro Alves
2013-11-19 15:47 ` Tom Tromey
2013-11-19 16:33 ` Pedro Alves
2013-11-19 19:07 ` Tom Tromey
2013-11-19 20:24 ` Pedro Alves
2013-11-19 20:56 ` Tom Tromey
2013-11-20 18:27 ` [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 Alves
2013-11-21 0:33 ` Tom Tromey
2013-11-21 16:40 ` Pedro Alves
2013-11-21 19:25 ` Tom Tromey
2013-11-22 14:13 ` [COMMITTED] Make use of the frame stash to detect wider stack cycles. (was: 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 Alves
2013-11-22 14:29 ` [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 Alves
2013-11-22 14:52 ` Pedro Alves [this message]
2013-11-22 17:16 ` [PATCH 1/2] avoid infinite loop with bad debuginfo Tom Tromey
2013-11-22 17:56 ` Pedro Alves
2013-11-19 15:52 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=528F6AC0.6020509@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox