public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "dtaylor at emc dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/17520] New: structure offset wrong when 1/4 GB or greater Date: Wed, 29 Oct 2014 14:36:00 -0000 [thread overview] Message-ID: <bug-17520-4717@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2014-10-29 14:36 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-10-29 14:36 dtaylor at emc dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-17520-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).