https://bugs.kde.org/show_bug.cgi?id=526648
Bug ID: 526648
Summary: --track-fds=yes with forkpty() causes a false positive
Classification: Developer tools
Product: valgrind
Version First 3.27 GIT
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: general
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
DESCRIPTION
A program that calls forkpty() incorrectly reports "File descriptor [X] was
never created".
uname -v: Linux <hostname> 7.2.5-200.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep
11 15:11:05 UTC 2026 x86_64 GNU/Linux
STEPS TO REPRODUCE
Run a program under valgrind with --track-fds=yes that calls forkpty()
OBSERVED RESULT
==642696== Memcheck, a memory error detector
==642696== Copyright (C) 2002-2026, and GNU GPL'd, by Julian Seward et al.
==642696== Using Valgrind-3.27.1-b50f9a09ca-20260520 and LibVEX; rerun with -h
for copyright info
==642696== Command: ./valgrind_forkpty_bug
==642696==
--642696-- Valgrind options:
--642696-- --verbose
--642696-- --track-fds=yes
--642696-- --enable-debuginfod=no
--642696-- Contents of /proc/version:
--642696-- Linux version 7.2.5-200.fc44.x86_64
(mockbuild@b7cf753306404a0aace7b8416a1a73b3) (gcc (GCC) 16.2.1 20260819 (Red
Hat 16.2.1-2), GNU ld version 2.46.1-1.fc44) #1 SMP PREEMPT_DYNAMIC Fri Sep 11
15:11:05 UTC 2026
--642696--
--642696-- Arch and hwcaps: AMD64, LittleEndian,
amd64-cx16-lzcnt-rdtscp-sse3-ssse3-avx-avx2-bmi-f16c-rdrand-rdseed-fma
--642696-- Page sizes: currently 4096, max supported 4096
--642696-- Valgrind library directory: /usr/libexec/valgrind
--642696-- Reading syms from /home/juta/c_play/valgrind_forkpty_bug
--642696-- Reading syms from /usr/lib64/ld-linux-x86-64.so.2
--642696-- Reading syms from /usr/libexec/valgrind/memcheck-amd64-linux
--642696-- object doesn't have a dynamic symbol table
--642696-- Scheduler: using generic scheduler lock implementation.
--642696-- Reading suppressions file: /usr/libexec/valgrind/default.supp
==642696== embedded gdbserver: reading from
/tmp/vgdb-pipe-from-vgdb-to-642696-by-juta-on-node-1w7jra1zts3xq3zyvb3vkytk9.ipv6.telus.net
==642696== embedded gdbserver: writing to
/tmp/vgdb-pipe-to-vgdb-from-642696-by-juta-on-node-1w7jra1zts3xq3zyvb3vkytk9.ipv6.telus.net
==642696== embedded gdbserver: shared mem
/tmp/vgdb-pipe-shared-mem-vgdb-642696-by-juta-on-node-1w7jra1zts3xq3zyvb3vkytk9.ipv6.telus.net
==642696==
==642696== TO CONTROL THIS PROCESS USING vgdb (which you probably
==642696== don't want to do, unless you know exactly what you're doing,
==642696== or are doing some strange experiment):
==642696== /usr/libexec/valgrind/../../bin/vgdb --pid=642696 ...command...
==642696==
==642696== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==642696== /path/to/gdb ./valgrind_forkpty_bug
==642696== and then give GDB the following command
==642696== target remote | /usr/libexec/valgrind/../../bin/vgdb --pid=642696
==642696== --pid is optional if only one valgrind process is running
==642696==
--642696-- REDIR: 0x40279e0 (ld-linux-x86-64.so.2:strlen) redirected to
0x582534dd (???)
--642696-- REDIR: 0x4026380 (ld-linux-x86-64.so.2:strcmp) redirected to
0x582534f7 (???)
--642696-- REDIR: 0x4026150 (ld-linux-x86-64.so.2:index) redirected to
0x58253530 (???)
--642696-- REDIR: 0x40254e0 (ld-linux-x86-64.so.2:bcmp) redirected to
0x58253512 (???)
--642696-- Reading syms from
/usr/libexec/valgrind/vgpreload_core-amd64-linux.so
--642696-- Reading syms from
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
==642696== WARNING: new redirection conflicts with existing -- ignoring it
--642696-- old: 0x04026380 (strcmp ) R-> (0000.0) 0x582534f7
???
--642696-- new: 0x04026380 (strcmp ) R-> (2016.0) 0x0484ccf0
strcmp
==642696== WARNING: new redirection conflicts with existing -- ignoring it
--642696-- old: 0x040279e0 (strlen ) R-> (0000.0) 0x582534dd
???
--642696-- new: 0x040279e0 (strlen ) R-> (2007.0) 0x0484b8c0
strlen
--642696-- REDIR: 0x40257b0 (ld-linux-x86-64.so.2:mempcpy) redirected to
0x4851420 (mempcpy)
--642696-- Reading syms from /usr/lib64/libc.so.6
--642696-- REDIR: 0x4027b80 (ld-linux-x86-64.so.2:strncmp) redirected to
0x484c490 (strncmp)
--642696-- REDIR: 0x4901af0 (libc.so.6:strnlen) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901b70 (libc.so.6:strpbrk) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48ffb40 (libc.so.6:strcmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4916fa0 (libc.so.6:wcsnlen) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48feb10 (libc.so.6:memset) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4916680 (libc.so.6:wcslen) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x49797d0 (libc.so.6:__memcpy_chk) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fea90 (libc.so.6:memrchr) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4916f40 (libc.so.6:wcsncpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fdf70 (libc.so.6:memcpy@@GLIBC_2.14) redirected to
0x483b4ba (_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4915420 (libc.so.6:wcschr) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48ffa40 (libc.so.6:index) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901ba0 (libc.so.6:rindex) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x49154c0 (libc.so.6:wcscmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fed70 (libc.so.6:stpncpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4923360 (libc.so.6:wmemchr) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901980 (libc.so.6:strncmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fede0 (libc.so.6:strcasecmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4900cb0 (libc.so.6:strcspn) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4916460 (libc.so.6:wcscpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48ff9d0 (libc.so.6:strcat) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901870 (libc.so.6:strncasecmp_l) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48ffac0 (libc.so.6:strchrnul) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fde80 (libc.so.6:bcmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4900c40 (libc.so.6:strcpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fee80 (libc.so.6:strcasecmp_l) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901750 (libc.so.6:strlen) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901a20 (libc.so.6:strncpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x49233e0 (libc.so.6:wmemcmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x49798e0 (libc.so.6:__memmove_chk) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
==642696== WARNING: new redirection conflicts with existing -- ignoring it
--642696-- old: 0x049c1250 (__memcpy_chk_avx_una) R-> (2030.0) 0x04851520
__memcpy_chk
--642696-- new: 0x049c1250 (__memcpy_chk_avx_una) R-> (2024.0) 0x04850e40
__memmove_chk
--642696-- REDIR: 0x48fed00 (libc.so.6:stpcpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fe870 (libc.so.6:memmove) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
==642696== Preferring higher priority redirection:
--642696-- old: 0x049c1280 (__memcpy_avx_unalign) R-> (2018.0) 0x0484e390
__memcpy_avx_unaligned_erms
--642696-- new: 0x049c1280 (__memcpy_avx_unalign) R-> (2018.1) 0x04850130
memmove
--642696-- REDIR: 0x48fde00 (libc.so.6:memchr) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4901dc0 (libc.so.6:strspn) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x4915060 (libc.so.6:wcpncpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x48fe980 (libc.so.6:mempcpy) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x49017d0 (libc.so.6:strncasecmp) redirected to 0x483b4ba
(_vgnU_ifunc_wrapper)
--642696-- REDIR: 0x49c5eb0 (libc.so.6:__strrchr_avx2) redirected to 0x484b020
(rindex)
==642697== File descriptor 4 was never created
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB765: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697== File descriptor 4 was never created
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB788: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697== File descriptor 4 was never created
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB7A8: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
--642696-- REDIR: 0x48fa8f0 (libc.so.6:free) redirected to 0x4844d01 (free)
--642697-- REDIR: 0x48fa8f0 (libc.so.6:free) redirected to 0x4844d01 (free)
==642696==
==642696== FILE DESCRIPTORS: 4 open (3 inherited) at exit.
==642696== Open file descriptor 3: /dev/ptmx
==642696== at 0x495FBD6: open (in /usr/lib64/libc.so.6)
==642696== by 0x49BBB91: openpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642696== by 0x49BA997: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642696== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642696==
==642696==
==642696== HEAP SUMMARY:
==642696== in use at exit: 0 bytes in 0 blocks
==642696== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==642696==
==642696== All heap blocks were freed -- no leaks are possible
==642696==
==642696== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==642697==
==642697== FILE DESCRIPTORS: 3 open (0 inherited) at exit.
==642697== Open file descriptor 2: /dev/pts/16
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB7A8: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697==
==642697== Open file descriptor 1: /dev/pts/16
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB788: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697==
==642697== Open file descriptor 0: /dev/pts/16
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB765: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697==
==642697==
==642697== HEAP SUMMARY:
==642697== in use at exit: 0 bytes in 0 blocks
==642697== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==642697==
==642697== All heap blocks were freed -- no leaks are possible
==642697==
==642697== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
==642697==
==642697== 1 errors in context 1 of 6:
==642697== File descriptor 4 was never created
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB7A8: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697==
==642697== 1 errors in context 2 of 6:
==642697== File descriptor 4 was never created
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB788: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697==
==642697== 1 errors in context 3 of 6:
==642697== File descriptor 4 was never created
==642697== at 0x495B60B: dup2 (in /usr/lib64/libc.so.6)
==642697== by 0x49BB765: login_tty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x49BA9EC: forkpty@@GLIBC_2.34 (in /usr/lib64/libc.so.6)
==642697== by 0x400498: main (in /home/juta/c_play/valgrind_forkpty_bug)
==642697== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 43 (Sway Spin)
Desktop/Window Manager: Sway
KDE Plasma Version: N/A
KDE Frameworks Version: N/A
--
You are receiving this mail because:
You are watching all bug changes.