This is the mail archive of the gdb-cvs@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]

src/gdb ChangeLog ada-lang.c


CVSROOT:	/cvs/src
Module name:	src
Changes by:	brobecke@sourceware.org	2010-11-23 01:07:22

Modified files:
	gdb            : ChangeLog ada-lang.c 

Log message:
	GDB SEGV while trying to print uninitialize variant record
	
	We have a variant record whose value is defined as follow:
	
	type Discriminant_Record (Num1, Num2,
	Num3, Num4 : Natural) is record
	Field1 : My_Record_Array (1 .. Num2);
	Field2 : My_Record_Array (Num1 .. 10);
	Field3 : My_Record_Array (Num1 .. Num2);
	Field4 : My_Record_Array (Num3 .. Num2);
	Field5 : My_Record_Array (Num4 .. Num2);
	end record;
	Dire : Discriminant_Record (1, 7, 3, 0);
	
	However, we're trying to print "Dire" before it is elaborated.
	This is common if one breaks on a function and then starts doing
	"info locals" for instance.
	
	What happens is that GDB reads bogus values for fields Num1 to
	Num4, and deduces a bogus (ginormouos) size for component
	"Field1".  The length is so large that it then later causes
	an overflow in the overall record length computation. Things
	go downhill from there, because length(field1) > length(record).
	So, when after we've fetched the value of the record based on
	the computed size, we crash trying to access unallocated memory
	when accessing field1...
	
	The first fix we can do is to check the size of the field
	against the maximum object size.  If it exceeds that size,
	then we know the record will also exceed that size...
	
	gdb/ChangeLog:
	
	* ada-lang.c (ada_template_to_fixed_record_type_1):
	For dynamic fields, check the field size against the maximum
	object size.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12334&r2=1.12335
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-lang.c.diff?cvsroot=src&r1=1.276&r2=1.277


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