From: "Maciej W. Rozycki" <macro@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [RFA] Fix inline frame crash in handle_inferior_event
Date: Wed, 13 Jun 2012 05:13:00 -0000 [thread overview]
Message-ID: <alpine.DEB.1.10.1206121703180.23962@tp.orcam.me.uk> (raw)
Hi,
Jan's recent change to enable mcheck has triggered a segfault in
gdb.opt/inline-cmds.exp on mips-sde-elf and mips-linux-gnu targets (any
multilibs). I have tracked the problem down to dereferencing a pointer to
a frame structure that has been already freed. The cause is in
handle_inferior_event, where skip_inline_frames is called and that may
invalidate the frame cache. That doesn't stop handle_inferior_event
though from trying to use a stale pointer to the current frame structure
in the next step. This path is only used for targets that have delay
slots (gdbarch_single_step_through_delay_p is true; that applies to CRIS
and MIPS targets only), which I infer is why it wasn't caught straight
away. This must be a long-standing bug.
The change below works for me, the gdbarch_single_step_through_delay_p
check that guards the problematic pointer dereference uses gdbarch
determined by the invalidated frame too, so I've decided to reinit both
frame and gdbarch unconditionally.
No regressions in mips-sde-elf, mips-linux-gnu or i686-linux-gnu targets.
OK to apply?
2012-06-13 Maciej W. Rozycki <macro@codesourcery.com>
gdb/
* infrun.c (handle_inferior_event): Re-fetch frame and gdbarch
after hiding inline functions.
Maciej
gdb-wait-inline-frames.diff
Index: gdb-fsf-trunk-quilt/gdb/infrun.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/infrun.c 2012-06-08 23:45:43.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/infrun.c 2012-06-12 08:29:31.063547656 +0100
@@ -4084,7 +4084,13 @@ handle_inferior_event (struct execution_
&& pc_at_non_inline_function (aspace,
ecs->event_thread->prev_pc,
&ecs->ws)))
- skip_inline_frames (ecs->ptid);
+ {
+ skip_inline_frames (ecs->ptid);
+ /* Re-fetch current thread's frame in case that invalidated
+ the frame cache. */
+ frame = get_current_frame ();
+ gdbarch = get_frame_arch (frame);
+ }
}
if (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP
next reply other threads:[~2012-06-13 5:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 5:13 Maciej W. Rozycki [this message]
2012-06-13 6:56 ` Jan Kratochvil
2012-06-14 21:16 ` Maciej W. Rozycki
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=alpine.DEB.1.10.1206121703180.23962@tp.orcam.me.uk \
--to=macro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).