This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix gdb crash during .debug_line parsing


> 2008-11-05  Andreas Schwab  <schwab@suse.de>
> 
> 	* dwarf2read.c (dwarf_decode_lines): Add checks for corrupted line
> 	number programs.

Funny, we had a very similar problem not very long ago...

> -      if (!decode_for_pst_p && lh->num_file_names >= file)
> +      if (!decode_for_pst_p && file != 0 && lh->num_file_names >= file)

I believe that this hunk is useless, since this check is at the
beginning of the while loop where file is initialized to 1, so
file can never be zero at this point.


> @@ -7102,7 +7109,7 @@ dwarf_decode_lines (struct line_header *
>  	      line += lh->line_base + (adj_opcode % lh->line_range);
>  	      if (lh->num_file_names < file)
>  		dwarf2_debug_line_missing_file_complaint ();
> -	      else
> +	      else if (file != 0)
>  		{
>  		  lh->file_names[file - 1].included_p = 1;
>  		  if (!decode_for_pst_p)

The problem I see with your approach is taht we don't get to
issue a complaint if file is zero.

Attached is the patch that we have checked in our tree. It handles
the incorrect file number as well as a missing end­sequence. Could
you test it on your side to see if it fixes your problem(s)?

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.

If it works for you, then I'll do a round of testing and commit
(I might have to fix some space-vs-tabs issues as well, sigh...).

-- 
Joel

Attachment: jerome.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]