Your message dated Thu, 20 Feb 2025 20:56:25 -0500
with message-id <[email protected]>
and subject line Re: Bug#1012562: gdb makes time(2) no longer returning correct 
value
has caused the Debian Bug report #1012562,
regarding gdb makes time(2) no longer returning correct value
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.)


-- 
1012562: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1012562
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: gdb
Version: 10.1-2+b1
Severity: important
X-Debbugs-Cc: [email protected]

Hello.

I'm actually not sure whether this is a GDB or a GLIBC bug, but I currently
can only reproduce this bug with gdb(1) (not strace(1) for exmaple).

I found one of my program starts to behave abnormally after I trying to
inspect its stack trace with gdb(1); further investigation indicates that the
program can no longer obtain the real time clock via time(2), but getting a
constant value which seems to be equal to the time when gdb(1) attached it.
Note the time(2) continue to return the constant value after the gdb(1)
detached it, which creates a major problem to the program.

The following test confirms the bug:

root@debian:~/src# cat time-test.c
#include <time.h>
#include <unistd.h>
#include <stdio.h>

int main() {
        while(1) {
                time_t t = time(&t);
                printf("%llu\n", (unsigned long long int)t);
                usleep(500000);
        }
}
root@debian:~/src# gcc -Wall -O1 time-test.c -o time-test
root@debian:~/src# ./time-test 
1654776779
1654776779
1654776780
1654776780
1654776781
^C
root@debian:~/src# gdb time-test
GNU gdb (Debian 10.1-2+b1) 10.1.90.20210103-git
Copyright (C) 2021 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 "powerpc64le-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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 time-test...
Download failed: Function not implemented.  Continuing without debug info for 
/root/src/time-test.
(No debugging symbols found in time-test)
(gdb) run
Starting program: /root/src/time-test 
1654776795
1654776795
1654776795
1654776795
1654776795
1654776795
1654776795
...


As it shows the time(2) function didn't work when the test program is running
under gdb(1).
The later test showing that the bug can be triggered by simply attaching and
detaching the test program using gdb(1), where time(2) stopped working even
after detaching:

root@debian:~/src# ./time-test & 
[1] 2990776
root@debian:~/src# 1654776843
1654776843
1654776844
1654776844
1654776845
...
1654776871
1654776871
1654776872
root@debian:~/src# printf 'detach\nquit\n' | gdb -p 2990776
GNU gdb (Debian 10.1-2+b1) 10.1.90.20210103-git
Copyright (C) 2021 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 "powerpc64le-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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".
Attaching to process 2990776
Reading symbols from /root/src/time-test...
Download failed: Function not implemented.  Continuing without debug info for 
/root/src/time-test.
(No debugging symbols found in /root/src/time-test)
Reading symbols from /lib/powerpc64le-linux-gnu/libc.so.6...
Reading symbols from 
/usr/lib/debug/.build-id/e5/2f41124ed3bb8fdc6115ac627e95f380ce8c27.debug...
Reading symbols from /lib64/ld64.so.2...
Reading symbols from 
/usr/lib/debug/.build-id/10/a885eed98381181a7cfb746c31afbe0756780f.debug...
0x00007fe0f420d714 in __GI___clock_nanosleep (clock_id=<optimized out>, 
flags=0, 
    req=0x7fffe71a08b8, rem=0x0) at 
../sysdeps/unix/sysv/linux/clock_nanosleep.c:43
Download failed: Function not implemented.  Continuing without source file 
./time/../sysdeps/unix/sysv/linux/clock_nanosleep.c.
43      ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory.
(gdb) Detaching from program: /root/src/time-test, process 2990776
[Inferior 1 (process 2990776) detached]
1654776872
(gdb) root@debian:~/src# 1654776872
1654776872
1654776872
1654776872
1654776872
1654776872
1654776872
...


-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: ppc64el (ppc64le)

Kernel: Linux 5.4.0-113-generic (SMP w/32 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=zh_TW.UTF-8, LC_CTYPE=zh_TW.UTF-8 (charmap=UTF-8), 
LANGUAGE=zh_TW:zh_CN:en_GB:en_US
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages gdb depends on:
ii  libbabeltrace1          1.5.8-2+b1
ii  libc6                   2.33-7
ii  libdebuginfod1          0.187-1
ii  libexpat1               2.4.8-1
ii  libgcc-s1               12.1.0-2
ii  liblzma5                5.2.5-2.1
ii  libmpfr6                4.1.0-3
ii  libncursesw6            6.3+20220423-2
ii  libpython3.10           3.10.4-4+b1
ii  libreadline8            8.1.2-1.2
ii  libsource-highlight4v5  3.1.9-4.1+b1
ii  libstdc++6              12.1.0-2
ii  libtinfo6               6.3+20220423-2
ii  libxxhash0              0.8.1-1
ii  zlib1g                  1:1.2.11.dfsg-4

Versions of packages gdb recommends:
ii  libc6-dbg [libc-dbg]  2.33-7

Versions of packages gdb suggests:
pn  gdb-doc    <none>
pn  gdbserver  <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
tags 1012562 + unreproducible
thanks

On Thursday, June 09 2022, WHR wrote:

> Hello.
>
> I'm actually not sure whether this is a GDB or a GLIBC bug, but I currently
> can only reproduce this bug with gdb(1) (not strace(1) for exmaple).

Thanks for the detailed bug report, and apologies for the long delay in
answering it.

> I found one of my program starts to behave abnormally after I trying to
> inspect its stack trace with gdb(1); further investigation indicates that the
> program can no longer obtain the real time clock via time(2), but getting a
> constant value which seems to be equal to the time when gdb(1) attached it.
> Note the time(2) continue to return the constant value after the gdb(1)
> detached it, which creates a major problem to the program.
>
> The following test confirms the bug:
>
> root@debian:~/src# cat time-test.c
> #include <time.h>
> #include <unistd.h>
> #include <stdio.h>
>
> int main() {
>       while(1) {
>               time_t t = time(&t);
>               printf("%llu\n", (unsigned long long int)t);
>               usleep(500000);
>       }
> }
> root@debian:~/src# gcc -Wall -O1 time-test.c -o time-test
> root@debian:~/src# ./time-test 
> 1654776779
> 1654776779
> 1654776780
> 1654776780
> 1654776781
> ^C
> root@debian:~/src# gdb time-test
> GNU gdb (Debian 10.1-2+b1) 10.1.90.20210103-git
> Copyright (C) 2021 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 "powerpc64le-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <https://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 time-test...
> Download failed: Function not implemented.  Continuing without debug info for 
> /root/src/time-test.
> (No debugging symbols found in time-test)
> (gdb) run
> Starting program: /root/src/time-test 
> 1654776795
> 1654776795
> 1654776795
> 1654776795
> 1654776795
> 1654776795
> 1654776795
> ...

I cannot reproduce the bug using GDB 16.2, which is what's in unstable
right now.

I also cannot reproduce with GDB 13.1, which is in bookworm.

I'm taking the liberty of closing this bug since it seems to have been
fixed.  Feel free to reopen if you're still experiencing it.

Cheers,

-- 
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