From: Paul Floyd Date: Fri, 24 Feb 2023 20:31:35 +0000 (+0100) Subject: bug465435 - m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit... X-Git-Tag: VALGRIND_3_21_0~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e61a04babcc3de8c1c86638f8ccdb4ef1b74a4d0;p=thirdparty%2Fvalgrind.git bug465435 - m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit)' failed. --- diff --git a/NEWS b/NEWS index 5e61efbbfe..7fcfc667a2 100644 --- a/NEWS +++ b/NEWS @@ -94,6 +94,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 464476 Firefox fails to start under Valgrind 464859 Build failures with GCC-13 (drd tsan_unittest) 464969 D language demangling +465435 m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit)' failed. To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index e98de3e96f..5d3a349f2b 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -57,13 +57,25 @@ Int VG_(safe_fd)(Int oldfd) vg_assert(VG_(fd_hard_limit) != -1); newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_(fd_hard_limit)); - if (newfd != -1) - VG_(close)(oldfd); + + if (newfd == -1) { + VG_(debugLog)(0, "libcfile", "Valgrind: FATAL: " + "Private file creation failed.\n" + " The current file descriptor limit is %d.\n" + " If you are running in Docker please consider\n" + " lowering this limit with the shell built-in limit command.\n", + VG_(fd_hard_limit)); + VG_(debugLog)(0, "libcfile", "Exiting now.\n"); + VG_(exit)(1); + } + + vg_assert(newfd >= VG_(fd_hard_limit)); + + VG_(close)(oldfd); /* Set the close-on-exec flag for this fd. */ VG_(fcntl)(newfd, VKI_F_SETFD, VKI_FD_CLOEXEC); - vg_assert(newfd >= VG_(fd_hard_limit)); return newfd; } @@ -753,7 +765,11 @@ Int VG_(fcntl) ( Int fd, Int cmd, Addr arg ) # else # error "Unknown OS" # endif - return sr_isError(res) ? -1 : sr_Res(res); + if (sr_isError(res)) { + VG_(debugLog)(1, "VG_(fcntl)", "fcntl error %lu %s\n", sr_Err(res), VG_(strerror)(sr_Err(res))); + return -1; + } + return (Int)sr_Res(res); } Int VG_(rename) ( const HChar* old_name, const HChar* new_name )