This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug tdep/10548] New: Segmentation error due to incomplete initialisation in sparc-tdep.c
- From: "andrew at ultrasoc dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 22 Aug 2009 13:32:19 -0000
- Subject: [Bug tdep/10548] New: Segmentation error due to incomplete initialisation in sparc-tdep.c
- Reply-to: sourceware-bugzilla at sourceware dot org
Hi,
I have been trying to use the latest snapshots (20090822) to debug a bare C
program running on a remote SPARC based embedded platform via a JTAG stub and
have experienced a few problems. I believe that I have identified a suitable,
solution to one problem which is as followed.
I run GDB with (-nx):
GNU gdb (GDB) 6.8.50.20090822
?
GDB was configured as "--host=i686-pc-mingw32 --target=sparc-elf"
?
I then connect to my target:
(gdb) tar extended-remote localhost:2222
GDB then segment faults. It looks to me as though on line 1380 of sparc-tdep.c
memory is allocated for the tdep structure and is subsequently not fully
initialised:
tdep = XMALLOC (struct gdbarch_tdep);
At some point later the following parts of the tdep are accessed without being
initialised.
tdep->sparc_psr_type
tdep->sparc_fsr_type
The following functions are used to provide initialisation:
[line 289]
static struct type * sparc_psr_type (struct gdbarch *gdbarch)
[line 312]
static struct type * sparc_fsr_type (struct gdbarch *gdbarch)
However, their initialisation is conditional ?if (!tdep->sparc_psr_type)? and
because the allocated memory is not cleared this initialisation fails and
subsequent accesses to tdep->sparc_psr_type or tdep->sparc_fsr_type result in a
segmentation error.
I have modified my local code so that on line 1381 the tdep is cleared before
any initialisation takes place.
memset(tdep, 0, sizeof(struct gdbarch_tdep));
I have tested this change and it seems to work as this specific problem goes away.
Kind regards.
--
Summary: Segmentation error due to incomplete initialisation in
sparc-tdep.c
Product: gdb
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tdep
AssignedTo: unassigned at sourceware dot org
ReportedBy: andrew at ultrasoc dot com
CC: gdb-prs at sourceware dot org
GCC build triplet: i686-pc-mingw32
GCC host triplet: i686-pc-mingw32
GCC target triplet: sparc-elf
http://sourceware.org/bugzilla/show_bug.cgi?id=10548
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.