This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[gdb patch] seg fault on missing dwarf
- From: Nathan Sidwell <nathan at acm dot org>
- To: gdb-patches at sourceware dot org
- Cc: palves at redhat dot com, alexander dot v dot shaposhnikov at gmail dot com
- Date: Mon, 25 Sep 2017 13:33:48 -0700
- Subject: [gdb patch] seg fault on missing dwarf
- Authentication-results: sourceware.org; auth=none
Pedro,
this is Alex's patch of
https://sourceware.org/ml/gdb-patches/2017-09/msg00745.html cleaned up
with changelog formatting. Alex is a fellow FaceBooker.
The patch looks obvious to me, particularly as a few lines down we have:
fprintf_unfiltered (gdb_stdlog,
" %s CUs, %s TUs\n",
pulongest (dwp_file->cus ? dwp_file->cus->nr_units : 0),
pulongest (dwp_file->tus ? dwp_file->tus->nr_units : 0));
to protect dump output from exactly this problem.
ok?
nathan
--
Nathan Sidwell
2017-09-25 Alexander Shaposhnikov <alexander.v.shaposhnikov@gmail.com>
* dwarf2read.c (open_and_init_dwp_file): Protect against dwp_file
having NULL cus or tus.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b1914cf..547e3f0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11185,7 +11185,8 @@ open_and_init_dwp_file (void)
dwp_file->tus = create_dwp_hash_table (dwp_file, 1);
/* The DWP file version is stored in the hash table. Oh well. */
- if (dwp_file->cus->version != dwp_file->tus->version)
+ if (dwp_file->cus && dwp_file->tus
+ && dwp_file->cus->version != dwp_file->tus->version)
{
/* Technically speaking, we should try to limp along, but this is
pretty bizarre. We use pulongest here because that's the established
@@ -11195,7 +11196,7 @@ open_and_init_dwp_file (void)
pulongest (dwp_file->cus->version),
pulongest (dwp_file->tus->version), dwp_name.c_str ());
}
- dwp_file->version = dwp_file->cus->version;
+ dwp_file->version = dwp_file->cus ? dwp_file->cus->version : 0;
if (dwp_file->version == 2)
bfd_map_over_sections (dwp_file->dbfd, dwarf2_locate_v2_dwp_sections,