b7.10110111 at gmail dot com
2016-01-18 11:38:34 UTC
https://sourceware.org/bugzilla/show_bug.cgi?id=19487
Bug ID: 19487
Summary: Result of call to __errno_location() is truncated to
32 bit on amd64
Product: gdb
Version: 7.10
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: b7.10110111 at gmail dot com
Target Milestone: ---
Consider the following C program:
#include <stdio.h>
#include <errno.h>
int main()
{
printf("%p\n",&errno);
}
If I run it in gdb, I get wrong results of attempt to print errno and even just
its location. Here's the debugging session log:
-------------------------------------------------
$ gdb -q ./gdb-bug -ex 'b main' -ex r
Reading symbols from ./gdb-bug...(no debugging symbols found)...done.
Breakpoint 1 at 0x40059a
Starting program: /tmp/gdb-bug
Breakpoint 1, 0x000000000040059a in main ()
(gdb) p/x __errno_location()
$1 = 0xf7fbf6a0
(gdb) p *__errno_location()
Cannot access memory at address 0xfffffffff7fbf6a0
(gdb) c
Continuing.
0x7ffff7fbf6a0
[Inferior 1 (process 869) exited normally]
----------------------------------------------------
See that "p/x" truncates the value to 32 bits, then "p *..." sign-extends the
result of truncation, while on "c" we get actual value printed by the program
itself, which is neither of the former two.
Bug ID: 19487
Summary: Result of call to __errno_location() is truncated to
32 bit on amd64
Product: gdb
Version: 7.10
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: b7.10110111 at gmail dot com
Target Milestone: ---
Consider the following C program:
#include <stdio.h>
#include <errno.h>
int main()
{
printf("%p\n",&errno);
}
If I run it in gdb, I get wrong results of attempt to print errno and even just
its location. Here's the debugging session log:
-------------------------------------------------
$ gdb -q ./gdb-bug -ex 'b main' -ex r
Reading symbols from ./gdb-bug...(no debugging symbols found)...done.
Breakpoint 1 at 0x40059a
Starting program: /tmp/gdb-bug
Breakpoint 1, 0x000000000040059a in main ()
(gdb) p/x __errno_location()
$1 = 0xf7fbf6a0
(gdb) p *__errno_location()
Cannot access memory at address 0xfffffffff7fbf6a0
(gdb) c
Continuing.
0x7ffff7fbf6a0
[Inferior 1 (process 869) exited normally]
----------------------------------------------------
See that "p/x" truncates the value to 32 bits, then "p *..." sign-extends the
result of truncation, while on "c" we get actual value printed by the program
itself, which is neither of the former two.
--
You are receiving this mail because:
You are on the CC list for the bug.
You are receiving this mail because:
You are on the CC list for the bug.