Your message dated Sun, 03 Aug 2025 19:14:34 -0400
with message-id <[email protected]>
and subject line Closing bug
has caused the Debian Bug report #862858,
regarding gdb fails to properly reload PIE executables
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
862858: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862858
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: gcc-6
Version: 6.3.0-18
Severity: important

Hi,

I am directing this bug as relevant to gcc package as this is my best
guess so far of a possible culprit. gdb is the package which has its
functionality affected.

Consider the following trivial code:
    #include <stdio.h>
    void a()
    {
        printf("Hello, world\n");
    }
    int main()
    {
        a();
        return 0;
    }

When debugging such a program with gdb, gdb notices if the binary changes
between two runs (within the same session). However, binaries created
with gcc as in packages 6.3.0-18 (or 6.3.0-16 in testing) are not
properly reloaded:

    localhost /tmp $ gcc -W -Wall -g a.c
    localhost /tmp $ gdb -q a.out
    Reading symbols from a.out...done.
    (gdb) b a
    Breakpoint 1 at 0x6b4: file a.c, line 5.
    (gdb) r
    Starting program: /tmp/a.out

    Breakpoint 1, a () at a.c:5
    5           printf("Hello, world\n");
    (gdb) shell gcc -W -Wall -g a.c
    (gdb) r
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    `/tmp/a.out' has changed; re-reading symbols.
    Error in re-setting breakpoint 1: Cannot access memory at address 0x55555555
46b0
    Starting program: /tmp/a.out
    Hello, world
    [Inferior 1 (process 22102) exited normally]
    (gdb) quit

Note that instructing gdb to explicitly reload the binary 
    localhost ~ $ dpkg -l gcc-6 gdb binutils | grep ^i
    ii  binutils       2.28-5       amd64        GNU assembler, linker and 
binary utilities
    ii  gcc-6          6.3.0-18     amd64        GNU C compiler
    ii  gdb            7.12-6       amd64        GNU Debugger

I've tried other gcc+gdb combinations.

Binary reload fails similarly in the following case:
    ubuntu 17.04 gdb 7.12.50.20170314-0ubuntu1 + gcc 6.3.0-2ubuntu1

Binary reloads fine in the following cases:
    debian testing, gdb 7.12-6 + home-compiled upstream gcc-7.1.0
    debian testing, gdb 7.12-6 + home-compiled upstream gcc-6.3.0
    debian testing, gdb 7.12-6 + gcc 5.4.1-4
    archlinux gdb 7.12.1 + gcc 6.3.1 20170306

On the gcc-6.3.0 I had, objdump -x a.out   tells, among other things:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00000000004003f0

while on the gcc-6.3.0-16 debian package, I have:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x0000000000000580


I would be happy to provide more information if needed.

Cheers,

E.




-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64
 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gcc-6 depends on:
ii  binutils      2.28-5
ii  cpp-6         6.3.0-18
ii  gcc-6-base    6.3.0-18
ii  libc6         2.24-10
ii  libcc1-0      6.3.0-18
ii  libgcc-6-dev  6.3.0-18
ii  libgcc1       1:6.3.0-18
ii  libgmp10      2:6.1.2+dfsg-1
ii  libisl15      0.18-1
ii  libmpc3       1.0.3-1+b2
ii  libmpfr4      3.1.5-1
ii  libstdc++6    6.3.0-18
ii  zlib1g        1:1.2.8.dfsg-5

Versions of packages gcc-6 recommends:
ii  libc6-dev  2.24-10

Versions of packages gcc-6 suggests:
ii  gcc-6-doc         6.3.0-1
pn  gcc-6-locales     <none>
ii  gcc-6-multilib    6.3.0-18
pn  libasan3-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libmpx2-dbg       <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
I can't reproduce this with GDB 16.3:

--8<---------------cut here---------------start------------->8---
(gdb) shell gcc -W -Wall -g -fPIE 1.c
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
`/root/a.out' has changed; re-reading symbols.
Starting program: /root/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, a () at 1.c:4
4               printf("Hello, world\n");
(gdb) shell gcc -W -Wall -g -fPIE 1.c
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
`/root/a.out' has changed; re-reading symbols.
Starting program: /root/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, a () at 1.c:4
4               printf("Hello, world\n");
--8<---------------cut here---------------end--------------->8---

I'm closing it.  Feel free to reopen if still applicable.

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
https://sergiodj.net/

Attachment: signature.asc
Description: PGP signature


--- End Message ---

Reply via email to