Package: gdb Version: 10.1-2+b1 Severity: important X-Debbugs-Cc: msl0000023...@gmail.com
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