public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/15695] New: value_struct_elt dereferences entire ptr chain?
@ 2013-06-27 20:24 dje at google dot com
  2013-08-01 23:59 ` [Bug symtab/15695] " cvs-commit at gcc dot gnu.org
  2024-01-11 16:43 ` ssbssa at sourceware dot org
  0 siblings, 2 replies; 3+ messages in thread
From: dje at google dot com @ 2013-06-27 20:24 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15695

            Bug ID: 15695
           Summary: value_struct_elt dereferences entire ptr chain?
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: minor
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com

While debugging an infinite loop in gdb I found it occurred here:

value_struct_elt:

    while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
      {
        *argp = value_ind (*argp);
        /* Don't coerce fn pointer to fn and then back again!  */
        if (TYPE_CODE (value_type (*argp)) != TYPE_CODE_FUNC)
          *argp = coerce_array (*argp);
        t = check_typedef (value_type (*argp));
      }

The comment for value_struct_elt says:

 /* Given *ARGP, a value of type (pointer to a)* structure/union,

There's no suggestion of *ARGP being a pointer to a pointer to a pointer to ...
a pointer to a struct/union.
If this is an ease of use feature for the user, this seems like too low a level
a routine to implement this feature.

One possibility is that the loop is just a simple way to handle ptr->ref, with
ptr->ptr->ptr->... being accidental fallout.

IWBN to clarify this.

The TYPE_CODE (value_type (*argp)) needs a call to check_typedef.

Another related bug is why is there a check for a function inside the loop?
We're only interested in structs/unions here.
I suspect it's because coerce_array is misnamed/confusing: it also coerces
functions to be pointer to functions.  And if we didn't do the check we would
be stuck in an infinite loop.  Alas we still are in an infinite loop if *argp
is ptr->typedef->func.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug symtab/15695] value_struct_elt dereferences entire ptr chain?
  2013-06-27 20:24 [Bug symtab/15695] New: value_struct_elt dereferences entire ptr chain? dje at google dot com
@ 2013-08-01 23:59 ` cvs-commit at gcc dot gnu.org
  2024-01-11 16:43 ` ssbssa at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2013-08-01 23:59 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15695

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
CVSROOT:    /cvs/src
Module name:    src
Changes by:    devans@sourceware.org    2013-08-01 23:59:48

Modified files:
    gdb            : ChangeLog valops.c 
    gdb/testsuite  : ChangeLog 
Added files:
    gdb/testsuite/gdb.base: func-ptr.c func-ptr.exp 

Log message:
    PR symtab/15695
    * valops.c (value_struct_elt): Add missing call to check_typedef.
    (value_find_oload_method_list): Ditto.

    testsuite/
    * gdb.base/func-ptr.exp: New file.
    * gdb.base/func-ptr.c: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15857&r2=1.15858
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valops.c.diff?cvsroot=src&r1=1.314&r2=1.315
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3755&r2=1.3756
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/func-ptr.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/func-ptr.exp.diff?cvsroot=src&r1=NONE&r2=1.1

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug symtab/15695] value_struct_elt dereferences entire ptr chain?
  2013-06-27 20:24 [Bug symtab/15695] New: value_struct_elt dereferences entire ptr chain? dje at google dot com
  2013-08-01 23:59 ` [Bug symtab/15695] " cvs-commit at gcc dot gnu.org
@ 2024-01-11 16:43 ` ssbssa at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: ssbssa at sourceware dot org @ 2024-01-11 16:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=15695

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org
   Target Milestone|---                         |7.7
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #2 from Hannes Domani <ssbssa at sourceware dot org> ---
Fixed since gdb-7.7.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-11 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-27 20:24 [Bug symtab/15695] New: value_struct_elt dereferences entire ptr chain? dje at google dot com
2013-08-01 23:59 ` [Bug symtab/15695] " cvs-commit at gcc dot gnu.org
2024-01-11 16:43 ` ssbssa at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).