Bug 69176 - Gdb gets in an infinite loop in working with the symbol table
Gdb gets in an infinite loop in working with the symbol table
Status: CLOSED RAWHIDE
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: gdb (Show other bugs)
2.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Elena Zannoni
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-07-18 13:32 EDT by Jim Nance
Modified: 2007-11-30 17:06 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-09-23 17:30:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
the file that gdb dislikes (434.38 KB, application/octet-stream)
2002-07-18 13:35 EDT, Jim Nance
no flags Details
Patch to GDB for corrupted cv type chains. (4.14 KB, patch)
2002-08-20 16:08 EDT, Jim Blandy
no flags Details | Diff
A patch that makes GDB print a warning instead of creating corrupt type structures. (4.96 KB, patch)
2002-08-20 16:21 EDT, Jim Blandy
no flags Details | Diff

  None (edit)
Description Jim Nance 2002-07-18 13:32:54 EDT
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 13:35:24 EDT
Created attachment 65844 [details]
the file that gdb dislikes
Comment 2 Trond Eivind Glomsrxd 2002-07-18 16:58:37 EDT
Any possibility of a reduced testcase?
Comment 3 Jim Nance 2002-07-19 08:32:50 EDT
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 16:08:12 EDT
Created attachment 71684 [details]
Patch to GDB for corrupted cv type chains.
Comment 5 Jim Blandy 2002-08-20 16:21:57 EDT
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 16:24:31 EDT
I've attached two patches that fixed a similar problem in the public GDB sources.

Comment 7 Jim Nance 2002-08-22 08:04:02 EDT
Ill give these patches a try
Comment 8 Jim Nance 2002-09-03 09:49:45 EDT
These patches seem to fix everything!  Thanks!
Comment 9 Elena Zannoni 2002-12-10 17:00:27 EST
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.


Note You need to log in before you can comment on or make changes to this bug.