Skip to content

Commit 8b230a6

Browse files
author
Mark Wielaard
committed
Don't warn about fcntl F_GETFD with --track-fds
fcntl F_GETFD is used to check if a file descriptor is valid, so only make sure it isn't a valgrind fd, otherwise we might warn, with --track-fds=bad for any bad fd. https://bugs.kde.org/show_bug.cgi?id=510436
1 parent ef3f78a commit 8b230a6

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
208208
509643 Add missing s390x-linux syswraps
209209
510169 Update the LTP version in valgrind testsuite to 20250930
210210
510292 Silence false positive failure of LTP munmap01
211+
510436 Don't warn about fcntl F_GETFD with --track-fds
211212
510694 Handle qExecAndArgs remote protocol packet
212213

213214
To see details of a given bug, visit

coregrind/m_syswrap/syswrap-linux.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7447,7 +7447,16 @@ PRE(sys_fcntl)
74477447
# endif
74487448
*flags |= SfMayBlock;
74497449

7450-
if (!ML_(fd_allowed)(ARG1, "fcntl", tid, False)) {
7450+
/* F_GETFD is used to check if a file descriptor is valid, so only
7451+
make sure it isn't a valgrind fd, otherwise we might warn, with
7452+
--track-fds=bad for any bad fd. */
7453+
if (ARG2 == VKI_F_GETFD) {
7454+
if (ARG1 >= VG_(fd_soft_limit) ||
7455+
ARG1 == VG_(log_output_sink).fd ||
7456+
ARG1 == VG_(xml_output_sink).fd) {
7457+
SET_STATUS_Failure (VKI_EBADF);
7458+
}
7459+
} else if (!ML_(fd_allowed)(ARG1, "fcntl", tid, False)) {
74517460
SET_STATUS_Failure (VKI_EBADF);
74527461
}
74537462
}
@@ -7563,8 +7572,17 @@ PRE(sys_fcntl64)
75637572
# endif
75647573
*flags |= SfMayBlock;
75657574

7566-
if (!ML_(fd_allowed)(ARG1, "fcntl64", tid, False)) {
7567-
SET_STATUS_Failure (VKI_EBADF);
7575+
/* F_GETFD is used to check if a file descriptor is valid, so only
7576+
make sure it isn't a valgrind fd, otherwise we might warn, with
7577+
--track-fds=bad for any bad fd. */
7578+
if (ARG2 == VKI_F_GETFD) {
7579+
if (ARG1 >= VG_(fd_soft_limit) ||
7580+
ARG1 == VG_(log_output_sink).fd ||
7581+
ARG1 == VG_(xml_output_sink).fd) {
7582+
SET_STATUS_Failure (VKI_EBADF);
7583+
}
7584+
} else if (!ML_(fd_allowed)(ARG1, "fcntl64", tid, False)) {
7585+
SET_STATUS_Failure (VKI_EBADF);
75687586
}
75697587
}
75707588

0 commit comments

Comments
 (0)