This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug corefiles/22795] New: Variables in the .bss section are printed as 32-bit


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

            Bug ID: 22795
           Summary: Variables in the .bss section are printed as 32-bit
           Product: gdb
           Version: 7.12.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: corefiles
          Assignee: unassigned at sourceware dot org
          Reporter: byron.c.hawkins at gmail dot com
  Target Milestone: ---

For example, the glibc loader (ld-linux.so) defines the static variable
"__environ" as a pointer, which on a 64-bit platform is a 64-bit value. GDB
prints this variable as a 32-bit value:

    (gdb) p __environ
    $0 = 0xffffe060

GDB also attempts to dereference the pointer as a sign-extended 32-bit value:

    (gdb) p *(char **) __environ
    Cannot access memory at address 0xffffffffffffe060

So that is a bug. The behavior is clearly incorrect according to the most
fundamental semantics of the runtime environment. 

Here is a workaround:

    (gdb) x/1xg &__environ
    0x7ffff7ffe060

    (gdb) p **(char ***) &__environ
    $1 = 0x7fffffffe461 "LC_PAPER=en_GB.UTF-8"


> gdb --version
GNU gdb (GDB) Fedora 7.12.1-48.fc25
...

> uname -a
Linux sureau 4.12.9-200.fc25.x86_64 #1 SMP Fri Aug 25 13:23:30 UTC 2017 x86_64
x86_64 x86_64 GNU/Linux

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]