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]

[commit] Fix "Corrupted DWARF expression" errors on large files


A Debian user, Sami Liedes, reported a strange error message that would
imply that his objects were corrupt:

        currentVersion = dwarf2_read_address: Corrupted DWARF expression.

What we eventually tracked down was that an overflow had occurred.  We
don't have an obvious maximum size for DWARF-2 location lists - so
we record the end of .debug_loc as their size, to prevent running into
uninitialized memory.  I stored the size in an unsigned short.  If
.debug_loc is >64k, then this will be truncated, and we may decide we
hit the end at an unfortunate moment.

The size is stored between two pointers in the baton already, wasting
space.  So there's no point being overly clever here; just make it an
unsigned long and our problems go away.

Tested on x86_64-linux and committed.

-- 
Daniel Jacobowitz
CodeSourcery

2007-01-27  Daniel Jacobowitz  <dan@codesourcery.com>

	* dwarf2loc.h (struct dwarf2_locexpr_baton): Change size to a long.
	(struct dwarf2_loclist_baton): Likewise.

Index: dwarf2loc.h
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.h,v
retrieving revision 1.6
diff -u -p -r1.6 dwarf2loc.h
--- dwarf2loc.h	17 Dec 2005 22:33:59 -0000	1.6
+++ dwarf2loc.h	5 Jan 2007 15:31:17 -0000
@@ -39,7 +39,7 @@ struct dwarf2_locexpr_baton
   gdb_byte *data;
 
   /* Length of the location expression.  */
-  unsigned short size;
+  unsigned long size;
 
   /* The objfile containing the symbol whose location we're computing.  */
   struct objfile *objfile;
@@ -55,7 +55,7 @@ struct dwarf2_loclist_baton
   gdb_byte *data;
 
   /* Length of the location list.  */
-  unsigned short size;
+  unsigned long size;
 
   /* The objfile containing the symbol whose location we're computing.  */
   /* Used (only???) by thread local variables.  The objfile in which


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