patches/gdb/6.3/740-debian_make-cv-type-crash.patch
changeset 330 447b203edc2e
parent 329 419d959441ed
child 331 0c05f9ea3254
     1.1 --- a/patches/gdb/6.3/740-debian_make-cv-type-crash.patch	Tue Aug 14 19:32:22 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,132 +0,0 @@
     1.4 -2004-11-04  Jim Blandy  <jimb@redhat.com>
     1.5 -
     1.6 -	* gdbtypes.c (make_qualified_type): Doc fix.  Add assertion to
     1.7 -	prevent cross-objfile references.
     1.8 -	(make_cv_type): Doc fix.  Don't create cross-objfile references,
     1.9 -	even for stub types.
    1.10 -	(replace_type): Add assertion to prevent cross-objfile references.
    1.11 -	(check_typedef): Never resolve a stub type by copying over a type
    1.12 -	from another file.
    1.13 -
    1.14 -Index: src/gdb/gdbtypes.c
    1.15 -===================================================================
    1.16 -RCS file: /big/fsf/rsync/src-cvs/src/gdb/gdbtypes.c,v
    1.17 -retrieving revision 1.92
    1.18 -retrieving revision 1.93
    1.19 -diff -u -p -r1.92 -r1.93
    1.20 ---- src/gdb/gdbtypes.c	8 Aug 2004 17:18:16 -0000	1.92
    1.21 -+++ src/gdb/gdbtypes.c	4 Nov 2004 17:50:16 -0000	1.93
    1.22 -@@ -433,7 +433,9 @@ address_space_int_to_name (int space_fla
    1.23 - }
    1.24 - 
    1.25 - /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
    1.26 --   If STORAGE is non-NULL, create the new type instance there.  */
    1.27 -+
    1.28 -+   If STORAGE is non-NULL, create the new type instance there.
    1.29 -+   STORAGE must be in the same obstack as TYPE.  */
    1.30 - 
    1.31 - static struct type *
    1.32 - make_qualified_type (struct type *type, int new_flags,
    1.33 -@@ -453,6 +455,12 @@ make_qualified_type (struct type *type, 
    1.34 -     ntype = alloc_type_instance (type);
    1.35 -   else
    1.36 -     {
    1.37 -+      /* If STORAGE was provided, it had better be in the same objfile as
    1.38 -+	 TYPE.  Otherwise, we can't link it into TYPE's cv chain: if one
    1.39 -+	 objfile is freed and the other kept, we'd have dangling
    1.40 -+	 pointers.  */
    1.41 -+      gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage));
    1.42 -+
    1.43 -       ntype = storage;
    1.44 -       TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
    1.45 -       TYPE_CHAIN (ntype) = ntype;
    1.46 -@@ -501,11 +509,12 @@ make_type_with_address_space (struct typ
    1.47 -    CNST is a flag for setting the const attribute
    1.48 -    VOLTL is a flag for setting the volatile attribute
    1.49 -    TYPE is the base type whose variant we are creating.
    1.50 --   TYPEPTR, if nonzero, points
    1.51 --   to a pointer to memory where the reference type should be stored.
    1.52 --   If *TYPEPTR is zero, update it to point to the reference type we return.
    1.53 --   We allocate new memory if needed.  */
    1.54 - 
    1.55 -+   If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
    1.56 -+   storage to hold the new qualified type; *TYPEPTR and TYPE must be
    1.57 -+   in the same objfile.  Otherwise, allocate fresh memory for the new
    1.58 -+   type whereever TYPE lives.  If TYPEPTR is non-zero, set it to the
    1.59 -+   new type we construct.  */
    1.60 - struct type *
    1.61 - make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
    1.62 - {
    1.63 -@@ -524,20 +533,19 @@ make_cv_type (int cnst, int voltl, struc
    1.64 - 
    1.65 -   if (typeptr && *typeptr != NULL)
    1.66 -     {
    1.67 --      /* Objfile is per-core-type.  This const-qualified type had best
    1.68 --	 belong to the same objfile as the type it is qualifying, unless
    1.69 --	 we are overwriting a stub type, in which case the safest thing
    1.70 --	 to do is to copy the core type into the new objfile.  */
    1.71 --
    1.72 --      gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type)
    1.73 --		  || TYPE_STUB (*typeptr));
    1.74 --      if (TYPE_OBJFILE (*typeptr) != TYPE_OBJFILE (type))
    1.75 --	{
    1.76 --	  TYPE_MAIN_TYPE (*typeptr)
    1.77 --	    = TYPE_ALLOC (*typeptr, sizeof (struct main_type));
    1.78 --	  *TYPE_MAIN_TYPE (*typeptr)
    1.79 --	    = *TYPE_MAIN_TYPE (type);
    1.80 --	}
    1.81 -+      /* TYPE and *TYPEPTR must be in the same objfile.  We can't have
    1.82 -+	 a C-V variant chain that threads across objfiles: if one
    1.83 -+	 objfile gets freed, then the other has a broken C-V chain.
    1.84 -+
    1.85 -+	 This code used to try to copy over the main type from TYPE to
    1.86 -+	 *TYPEPTR if they were in different objfiles, but that's
    1.87 -+	 wrong, too: TYPE may have a field list or member function
    1.88 -+	 lists, which refer to types of their own, etc. etc.  The
    1.89 -+	 whole shebang would need to be copied over recursively; you
    1.90 -+	 can't have inter-objfile pointers.  The only thing to do is
    1.91 -+	 to leave stub types as stub types, and look them up afresh by
    1.92 -+	 name each time you encounter them.  */
    1.93 -+      gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type));
    1.94 -     }
    1.95 -   
    1.96 -   ntype = make_qualified_type (type, new_flags, typeptr ? *typeptr : NULL);
    1.97 -@@ -562,6 +570,12 @@ replace_type (struct type *ntype, struct
    1.98 - {
    1.99 -   struct type *chain;
   1.100 - 
   1.101 -+  /* These two types had better be in the same objfile.  Otherwise,
   1.102 -+     the assignment of one type's main type structure to the other
   1.103 -+     will produce a type with references to objects (names; field
   1.104 -+     lists; etc.) allocated on an objfile other than its own.  */
   1.105 -+  gdb_assert (TYPE_OBJFILE (ntype) == TYPE_OBJFILE (ntype));
   1.106 -+
   1.107 -   *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
   1.108 - 
   1.109 -   /* The type length is not a part of the main type.  Update it for each
   1.110 -@@ -1416,8 +1430,24 @@ check_typedef (struct type *type)
   1.111 - 	  return type;
   1.112 - 	}
   1.113 -       newtype = lookup_transparent_type (name);
   1.114 -+
   1.115 -       if (newtype)
   1.116 --	make_cv_type (is_const, is_volatile, newtype, &type);
   1.117 -+	{
   1.118 -+	  /* If the resolved type and the stub are in the same objfile,
   1.119 -+	     then replace the stub type with the real deal.  But if
   1.120 -+	     they're in separate objfiles, leave the stub alone; we'll
   1.121 -+	     just look up the transparent type every time we call
   1.122 -+	     check_typedef.  We can't create pointers between types
   1.123 -+	     allocated to different objfiles, since they may have
   1.124 -+	     different lifetimes.  Trying to copy NEWTYPE over to TYPE's
   1.125 -+	     objfile is pointless, too, since you'll have to move over any
   1.126 -+	     other types NEWTYPE refers to, which could be an unbounded
   1.127 -+	     amount of stuff.  */
   1.128 -+	  if (TYPE_OBJFILE (newtype) == TYPE_OBJFILE (type))
   1.129 -+	    make_cv_type (is_const, is_volatile, newtype, &type);
   1.130 -+	  else
   1.131 -+	    type = newtype;
   1.132 -+	}
   1.133 -     }
   1.134 -   /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
   1.135 -   else if (TYPE_STUB (type) && !currently_reading_symtab)