From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: insight@sourceware.org
Subject: segfault on opening a register window
Date: Tue, 07 Sep 2010 14:19:00 -0000 [thread overview]
Message-ID: <20100907.231749.260982118.anemo@mba.ocn.ne.jp> (raw)
The insight crashes with segfault when opening a register window after
connecting to a remote ARM target. I confirmed the problem with 7.0.1,
7.1 and current CVS.
The crash happened here:
Program received signal SIGSEGV, Segmentation fault.
get_register (regnum=0, arg={integer = 0, ptr = 0x0})
at ../../insight/src/gdb/gdbtk/generic/gdbtk-register.c:341
341 if ((TYPE_CODE (reg_vtype) == TYPE_CODE_UNION)
(gdb) p reg_vtype
$1 = (struct type *) 0x66
The reg_vtype pointer had a wrong value. I realized that contents of
regtype[] array are corrupted. This is because current gdbarch was
changed but regformat or regtype array was not reconstructed.
1. start insight.
2. setup_architecture_data() was called.
3. connecting to a remote target, then gdbarch (also numregs) changed.
4. gdb_regformat() was called and write to outside of allocated
regformat, regtype array.
The problem is setup_architecture_data() is not called when gdbarch
was changed. If I opened the register window _before_ connecting to
a remote target, setup_architecture_data() is called via
gdb_reg_arch_changed. But it seems gdb_reg_arch_changed is called
only if the register windows was opened.
Here is a quick workaround. Is there good way to call
setup_architecture_data() automatically if current arch was changed?
Or other good fix?
--- gdb/gdbtk/generic/gdbtk-register.c.org 2010-09-07 23:06:48.000000000 +0900
+++ gdb/gdbtk/generic/gdbtk-register.c 2010-09-07 23:06:59.000000000 +0900
@@ -65,6 +65,7 @@ static void get_register_types (int regn
static char *old_regs = NULL;
static int *regformat = (int *)NULL;
static struct type **regtype = (struct type **)NULL;
+static struct gdbarch *cur_gdbarch = NULL;
int
Gdbtk_Register_Init (Tcl_Interp *interp)
@@ -149,6 +150,10 @@ gdb_register_info (ClientData clientData
return TCL_ERROR;
}
+ /* Check gdbarch change to avoid corruption of regformat/regtype array */
+ if (cur_gdbarch != get_current_arch ())
+ setup_architecture_data ();
+
/* Skip the option */
objc -= 2;
objv += 2;
@@ -469,6 +474,7 @@ setup_architecture_data ()
{
int numregs;
+ cur_gdbarch = get_current_arch ();
xfree (old_regs);
xfree (regformat);
xfree (regtype);
---
Atsushi Nemoto
next reply other threads:[~2010-09-07 14:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-07 14:19 Atsushi Nemoto [this message]
2011-12-13 16:22 Yurij Grechishhev
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=20100907.231749.260982118.anemo@mba.ocn.ne.jp \
--to=anemo@mba.ocn.ne.jp \
--cc=insight@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).