public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/17520] New: structure offset wrong when 1/4 GB or greater
@ 2014-10-29 14:36 dtaylor at emc dot com
  2014-11-23 19:39 ` [Bug gdb/17520] " jan.kratochvil at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dtaylor at emc dot com @ 2014-10-29 14:36 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 17520
           Summary: structure offset wrong when 1/4 GB or greater
           Product: gdb
           Version: 7.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: dtaylor at emc dot com

When a structure member's offset is 1/4 GB or greater from the start
of the structure, GDB computes the wrong value.

When computing the offset of a structure member, GDB computes first
the BITS from the start of the structure, returns that as a 32 bit
signed quantity and then divides the result by 8.

While this can show up on 32 bit systems, it is especially bad on
64 bit systems.  We have systems with over 500 GB of memory and have
run into the problem.

Here's a short program that illustrates the bug.  The actual struct
where the problem was observed has over 250 members and is over 1/2 GB
in size.

#include <stdio.h>

struct big_struct
{
  char first[0x10000000 + 16];
  long second;
} big_struct;

int
main (int argc, char *argv[])
{
  printf ("sizeof (big_struct) 0x%lx,\n&big_struct %p,\n&big_struct.second
%p\noffset %lx\n",
      sizeof (big_struct),
      (void *)&big_struct,
      (void *)&big_struct.second,
      __builtin_offsetof(struct big_struct, second));
  return (0);
}

If I run it, the output is:

    sizeof (big_struct) 0x10000018,
    &big_struct 0x601040,
    &big_struct.second 0x10601050
    offset 10000010

But, in GDB 7.8:

    (gdb) p &big_struct
    $1 = (struct big_struct *) 0x601040 <big_struct>
    (gdb) p &big_struct.second
    $2 = (long *) 0xfffffffff0601050

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


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

end of thread, other threads:[~2015-05-03 12:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29 14:36 [Bug gdb/17520] New: structure offset wrong when 1/4 GB or greater dtaylor at emc dot com
2014-11-23 19:39 ` [Bug gdb/17520] " jan.kratochvil at redhat dot com
2014-11-24 20:41 ` sergiodj at redhat dot com
2014-11-24 20:49 ` jan.kratochvil at redhat dot com
2014-11-24 21:32 ` dtaylor at usendtaylorx2l dot lss.emc.com
2015-05-03 12:01 ` jburgess777 at gmail dot com

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).