From: Joel Brobecker <brobecker@adacore.com>
To: Andreas Schwab <schwab@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: Fix gdb crash during .debug_line parsing
Date: Mon, 10 Nov 2008 19:05:00 -0000 [thread overview]
Message-ID: <20081110184945.GH5112@adacore.com> (raw)
In-Reply-To: <20081109172512.GB5112@adacore.com>
> 2008-11-09 Jerome Guitton <guitton@adacore.com>
>
>
> * dwarf2read.c (dwarf2_debug_line_missing_end_sequence_complaint):
> New function.
> (dwarf_decode_lines): Detect null file numbers. Detect the end of
> the line program sequence when no end sequence is emitted.
Now re-tested on x86-linux, with no regression. Andreas confirmed that
it looks good to him too, so I will commit this in a couple of days
unless there are some objections.
Index: dwarf2read.c
===================================================================
--- dwarf2read.c (revision 134708)
+++ dwarf2read.c (revision 134718)
@@ -695,6 +695,13 @@ dwarf2_debug_line_missing_file_complaint
}
static void
+dwarf2_debug_line_missing_end_sequence_complaint (void)
+{
+ complaint (&symfile_complaints,
+ _(".debug_line section has line program sequence without an end"));
+}
+
+static void
dwarf2_complex_location_expr_complaint (void)
{
complaint (&symfile_complaints, _("location expression too complex"));
@@ -7253,6 +7260,11 @@ dwarf_decode_lines (struct line_header *
{
op_code = read_1_byte (abfd, line_ptr);
line_ptr += 1;
+ if (line_ptr > line_end)
+ {
+ dwarf2_debug_line_missing_end_sequence_complaint ();
+ break;
+ }
if (op_code >= lh->opcode_base)
{
@@ -7261,7 +7273,7 @@ dwarf_decode_lines (struct line_header *
address += (adj_opcode / lh->line_range)
* lh->minimum_instruction_length;
line += lh->line_base + (adj_opcode % lh->line_range);
- if (lh->num_file_names < file)
+ if (lh->num_file_names < file || file == 0)
dwarf2_debug_line_missing_file_complaint ();
else
{
@@ -7293,15 +7305,6 @@ dwarf_decode_lines (struct line_header *
{
case DW_LNE_end_sequence:
end_sequence = 1;
-
- if (lh->num_file_names < file)
- dwarf2_debug_line_missing_file_complaint ();
- else
- {
- lh->file_names[file - 1].included_p = 1;
- if (!decode_for_pst_p)
- record_line (current_subfile, 0, address);
- }
break;
case DW_LNE_set_address:
address = read_address (abfd, line_ptr, cu, &bytes_read);
@@ -7343,7 +7346,7 @@ dwarf_decode_lines (struct line_header *
}
break;
case DW_LNS_copy:
- if (lh->num_file_names < file)
+ if (lh->num_file_names < file || file == 0)
dwarf2_debug_line_missing_file_complaint ();
else
{
@@ -7381,7 +7384,7 @@ dwarf_decode_lines (struct line_header *
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
- if (lh->num_file_names < file)
+ if (lh->num_file_names < file || file == 0)
dwarf2_debug_line_missing_file_complaint ();
else
{
@@ -7432,6 +7435,14 @@ dwarf_decode_lines (struct line_header *
}
}
}
+ if (lh->num_file_names < file || file == 0)
+ dwarf2_debug_line_missing_file_complaint ();
+ else
+ {
+ lh->file_names[file - 1].included_p = 1;
+ if (!decode_for_pst_p)
+ record_line (current_subfile, 0, address);
+ }
}
if (decode_for_pst_p)
next prev parent reply other threads:[~2008-11-10 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 12:53 Andreas Schwab
2008-11-09 17:25 ` Joel Brobecker
2008-11-09 18:32 ` Andreas Schwab
2008-11-10 19:05 ` Joel Brobecker [this message]
2008-11-16 8:18 ` Joel Brobecker
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=20081110184945.GH5112@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=schwab@suse.de \
/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