Bug 69176

Summary: Gdb gets in an infinite loop in working with the symbol table
Product: Red Hat Enterprise Linux 2.1 Reporter: Jim Nance <jlnance>
Component: gdbAssignee: Elena Zannoni <ezannoni>
Status: CLOSED RAWHIDE QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-09-23 21:30:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
the file that gdb dislikes
none
Patch to GDB for corrupted cv type chains.
none
A patch that makes GDB print a warning instead of creating corrupt type structures. none

Description Jim Nance 2002-07-18 17:32:54 UTC
Description of Problem:
Gdb hangs in the function finish_cv_type() for ever.  I was able to work around
the problem by modifying the gdb source as shown below:

/* When reading in a class type, we may have created references to
   cv-qualified versions of the type (in method arguments, for
   instance).  Update everything on the cv ring from the primary
   type TYPE.

   The only reason we do not need to do the same thing for address
   spaces is that type readers do not create address space qualified
   types.  */
void
finish_cv_type (struct type *type)
{
  int cnt=0;
  struct type *ntype, *cv_type, *ptr_type, *ref_type;
  int cv_flags;

  gdb_assert (!TYPE_CONST (type) && !TYPE_VOLATILE (type));

  ntype = type;
  while ((ntype = TYPE_CV_TYPE (ntype)) != type)
    {
      if(++cnt>10000) break;
      /* Save cv_flags.  */
      cv_flags = TYPE_FLAGS (ntype) & (TYPE_FLAG_VOLATILE | TYPE_FLAG_CONST);

      /* If any reference or pointer types were created, save them too.  */
      ptr_type = TYPE_POINTER_TYPE (ntype);
      ref_type = TYPE_REFERENCE_TYPE (ntype);

      /* Don't disturb the CV chain.  */
      cv_type = TYPE_CV_TYPE (ntype);

      /* Verify that we haven't added any address-space qualified types,
         for the future.  */
      gdb_assert (ntype == TYPE_AS_TYPE (ntype));

      /* Copy original type */
      memcpy ((char *) ntype, (char *) type, sizeof (struct type));

      /* Restore everything.  */
      TYPE_POINTER_TYPE (ntype) = ptr_type;
      TYPE_REFERENCE_TYPE (ntype) = ref_type;
      TYPE_CV_TYPE (ntype) = cv_type;
      TYPE_FLAGS (ntype) = TYPE_FLAGS (ntype) | cv_flags;

      TYPE_AS_TYPE (ntype) = ntype;
    }
}

I added the cnt variable and the code to break out of the loop.  This makes the
problem go away and does not seem to have any ill effects.  Im not suggesting
this as the way to fix the problem, just to point out where it is.


Version-Release number of selected component (if applicable):

It happens with the gdb in 7.2, 7.3, and the gdb-5.2-2 update to 7.3

How Reproducible:

I can reproduce this but I unfortunatly cant send you the code :-(  I have
narrowed it down and found that if I compile one file with out -g the problem 
goes away.  I am going to attach the resulting dot.o file, compiled with -g,
in case it helps

Comment 1 Jim Nance 2002-07-18 17:35:24 UTC
Created attachment 65844 [details]
the file that gdb dislikes

Comment 2 Trond Eivind Glomsrxd 2002-07-18 20:58:37 UTC
Any possibility of a reduced testcase?

Comment 3 Jim Nance 2002-07-19 12:32:50 UTC
So far I have only seen it show up when trying to debug a large application.  I
can try and see if I can create a stripped down testcase, but I dont know how
long that will take me.

Comment 4 Jim Blandy 2002-08-20 20:08:12 UTC
Created attachment 71684 [details]
Patch to GDB for corrupted cv type chains.

Comment 5 Jim Blandy 2002-08-20 20:21:57 UTC
Created attachment 71685 [details]
A patch that makes GDB print a warning instead of creating corrupt type structures.

Comment 6 Jim Blandy 2002-08-20 20:24:31 UTC
I've attached two patches that fixed a similar problem in the public GDB sources.



Comment 7 Jim Nance 2002-08-22 12:04:02 UTC
Ill give these patches a try

Comment 8 Jim Nance 2002-09-03 13:49:45 UTC
These patches seem to fix everything!  Thanks!

Comment 9 Elena Zannoni 2002-12-10 22:00:27 UTC
The function that produces the infinite loop (finish_cv_type) is no longet in
the current
gdb sources. The problem will be resolved in the next RedHat version of gdb.