Bug 23210 - [8.1/8.2 Regression] Bogus Breakpoint address adjusted from 0xf7fe7dd3 to 0xfffffffff7fe7dd3.
Summary: [8.1/8.2 Regression] Bogus Breakpoint address adjusted from 0xf7fe7dd3 to 0xf...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: 8.1.1
: P2 normal
Target Milestone: 8.1.1
Assignee: Omair Javaid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-21 15:27 UTC by H.J. Lu
Modified: 2018-07-06 15:30 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2018-05-21 15:27:47 UTC
On x86-64, I got

(gdb) file /export/build/gnu/gdb/build-x86_64-linux/gdb/testsuite/outputs/gdb.multi/multi-arch-exec/2-multi-arch-exec^M
Reading symbols from /export/build/gnu/gdb/build-x86_64-linux/gdb/testsuite/outputs/gdb.multi/multi-arch-exec/2-multi-arch-exec...done.^M
(gdb) delete breakpoints^M
(gdb) info breakpoints^M
No breakpoints or watchpoints.^M
(gdb) break all_started^M
Breakpoint 1 at 0x804923b: file /export/gnu/import/git/sources/binutils-gdb/gdb/testsuite/gdb.multi/multi-arch-exec.c, line 42.^M
(gdb) run ^M
Starting program: /export/build/gnu/gdb/build-x86_64-linux/gdb/testsuite/outputs/gdb.multi/multi-arch-exec/2-multi-arch-exec ^M
warning: Breakpoint address adjusted from 0xf7fd6b51 to 0xfffffffff7fd6b51.^M
warning: Breakpoint address adjusted from 0xf7fd7529 to 0xfffffffff7fd7529.^M
warning: Breakpoint address adjusted from 0xf7fd9a8c to 0xfffffffff7fd9a8c.^M
warning: Breakpoint address adjusted from 0xf7fd9614 to 0xfffffffff7fd9614.^M
warning: Breakpoint address adjusted from 0xf7fe7dd3 to 0xfffffffff7fe7dd3.^M
warning: Breakpoint address adjusted from 0xf7fe8a56 to 0xfffffffff7fe8a56.^M
warning: Breakpoint address adjusted from 0xf7fe8d14 to 0xfffffffff7fe8d14.^M
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
On x86-64, address should be zero-extended, not sign-extended.
FAIL: gdb.multi/multi-arch-exec.exp: first_arch=2: selected_thread=2: follow_exec_mode=same: couldn't run to all_started
Comment 1 H.J. Lu 2018-05-21 15:48:36 UTC
CORE_ADDR
address_significant (gdbarch *gdbarch, CORE_ADDR addr)
{
  /* Clear insignificant bits of a target address and sign extend resulting
     address, avoiding shifts larger or equal than the width of a CORE_ADDR.
     The local variable ADDR_BIT stops the compiler reporting a shift overflow
     when it won't occur.  */
  int addr_bit = gdbarch_significant_addr_bit (gdbarch);

  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
    {
      CORE_ADDR sign = (CORE_ADDR) 1 << (addr_bit - 1);
      addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
      addr = (addr ^ sign) - sign;
    }      

  return addr;
}

is wrong for x86.
Comment 2 H.J. Lu 2018-05-21 15:56:00 UTC
[hjl@gnu-skl-1 gdb]$ cat x.c
#include <stdio.h>

int
main ()
{
  printf ("hello\n");
  return 0;
}
[hjl@gnu-skl-1 gdb]$ gcc -g x.c -m32 -fPIE -pie
[hjl@gnu-skl-1 gdb]$ gdb a.out 
GNU gdb (GDB) Fedora 8.1-15.fc28
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) b main
Breakpoint 1 at 0x11c6: file x.c, line 6.
(gdb) r
Starting program: /export/build/gnu/gdb/build-x86_64-linux/gdb/a.out 
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.27-14.1.fc28.i686

Breakpoint 1, main () at x.c:6
6	  printf ("hello\n");
(gdb) q
A debugging session is active.

	Inferior 1 [process 25461] will be killed.

Quit anyway? (y or n) y
[hjl@gnu-skl-1 gdb]$ ./gdb a.out 
Exception caught while booting Guile.
Error in function "open-file":
No such file or directory: "/usr/local/share/gdb/guile/gdb/boot.scm"
./gdb: warning: Could not complete Guile gdb module initialization from:
/usr/local/share/gdb/guile/gdb/boot.scm.
Limited Guile support is available.
Suggest passing --data-directory=/path/to/gdb/data-directory.

Python Exception <type 'exceptions.ImportError'> No module named gdb: 
./gdb: warning: 
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.

GNU gdb (GDB) 8.1.50.20180521-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) b main
Breakpoint 1 at 0x11c6: file x.c, line 6.
(gdb) r
Starting program: /export/build/gnu/gdb/build-x86_64-linux/gdb/a.out 
warning: Breakpoint address adjusted from 0xf7fd6b51 to 0xfffffffff7fd6b51.
warning: Breakpoint address adjusted from 0xf7fd7529 to 0xfffffffff7fd7529.
warning: Breakpoint address adjusted from 0xf7fd9a8c to 0xfffffffff7fd9a8c.
warning: Breakpoint address adjusted from 0xf7fd9614 to 0xfffffffff7fd9614.
warning: Breakpoint address adjusted from 0xf7fe7dd3 to 0xfffffffff7fe7dd3.
warning: Breakpoint address adjusted from 0xf7fe8a56 to 0xfffffffff7fe8a56.
warning: Breakpoint address adjusted from 0xf7fe8d14 to 0xfffffffff7fe8d14.

Program received signal SIGINT, Interrupt.
Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing: 
0xf7fd6b51 in ?? () from /lib/ld-linux.so.2
(gdb)
Comment 3 H.J. Lu 2018-05-21 16:04:58 UTC
This is caused by

commit 8727de56b0dbe25b7b4a3bd04f72ac41992463ed (HEAD)
Author: Omair Javaid <omair.javaid@linaro.org>
Date:   Tue May 1 06:31:32 2018 +0500

    Fix tagged pointer support
Comment 4 Joel Brobecker 2018-05-21 17:20:12 UTC
A quick note to confirm that the patch identified as triggering the issue was backported to the 8.1 branch, so that would explain why 8.1 is impacted.
Comment 5 Sourceware Commits 2018-05-31 02:32:13 UTC
The master branch has been updated by Omair Javaid <omjavaid@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5969f0dba74e17c694faf333b120f1e0b95783ed

commit 5969f0dba74e17c694faf333b120f1e0b95783ed
Author: Omair Javaid <omair.javaid@linaro.org>
Date:   Sat May 26 05:58:51 2018 +0500

    Unset gdbarch significant_addr_bit by default
    
    This patch fixes a bug introduced by fix to AArch64 pointer tagging.
    
    In our fix for tagged pointer support our agreed approach was to sign
    extend user-space address after clearing tag bits. This is not same
    for all architectures and this patch allows sign extension for
    addresses on targets which specifically set significant_addr_bit.
    
    More information about patch that caused the issues and discussion
    around tagged pointer support can be found in links below:
    
    https://sourceware.org/ml/gdb-patches/2018-05/msg00000.html
    https://sourceware.org/ml/gdb-patches/2017-12/msg00159.html
    
    gdb/ChangeLog:
    
    2018-05-31  Omair Javaid  <omair.javaid@linaro.org>
    
    	PR gdb/23210
    	* gdbarch.sh (significant_addr_bit): Default to zero when
    	not set by target architecture.
    	* gdbarch.c: Re-generated.
    	* utils.c (address_significant): Update.
Comment 6 Sourceware Commits 2018-05-31 03:29:48 UTC
The gdb-8.1-branch branch has been updated by Omair Javaid <omjavaid@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8679931c2c9f97ad182f8f0a9e8fab20305719b5

commit 8679931c2c9f97ad182f8f0a9e8fab20305719b5
Author: Omair Javaid <omair.javaid@linaro.org>
Date:   Sat May 26 05:58:51 2018 +0500

    Unset gdbarch significant_addr_bit by default
    
    This patch fixes a bug introduced by fix to AArch64 pointer tagging.
    
    In our fix for tagged pointer support our agreed approach was to sign
    extend user-space address after clearing tag bits. This is not same
    for all architectures and this patch allows sign extension for
    addresses on targets which specifically set significant_addr_bit.
    
    More information about patch that caused the issues and discussion
    around tagged pointer support can be found in links below:
    
    https://sourceware.org/ml/gdb-patches/2018-05/msg00000.html
    https://sourceware.org/ml/gdb-patches/2017-12/msg00159.html
    
    gdb/ChangeLog:
    
    2018-05-31  Omair Javaid  <omair.javaid@linaro.org>
    
    	PR gdb/23210
    	* gdbarch.sh (significant_addr_bit): Default to zero when
    	not set by target architecture.
    	* gdbarch.c: Re-generated.
    	* utils.c (address_significant): Update.
Comment 7 Pedro Alves 2018-07-06 15:30:05 UTC
Fix was merged a while ago.  Closing.