From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31420 invoked by alias); 29 Oct 2014 14:36:56 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 31393 invoked by uid 48); 29 Oct 2014 14:36:55 -0000 From: "dtaylor at emc dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 7.8 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dtaylor at emc dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-q4/txt/msg00138.txt.bz2 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 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 (gdb) p &big_struct.second $2 = (long *) 0xfffffffff0601050 -- You are receiving this mail because: You are on the CC list for the bug.