https://bugs.kde.org/show_bug.cgi?id=465435

--- Comment #10 from Paul Floyd <pjfl...@wanadoo.fr> ---
(In reply to Corentin Noël from comment #9)

> In this case it seems that I'm getting an error on file descriptor
> duplication so having a errno/errmsg would also help understanding it a bit.

We can't provide anything from errno as we don't have it. Valgrind does not
link with libc and makes system calls like

   SysRes res = VG_(do_syscall3)(__NR_fcntl, fd, cmd, arg);

directly itself.

I really think that the problem is with Docker. It's advertising some
ridiculously high value for ulimit -n like 1048576. Valgrind wants to put its
own files in the top 12 of those slots, and is trying to to a fcntl(oldfd,
F_DUPFD, 1048576-12) - note that 1048576-12 matches the 1048564 that you get
from the patch message. Then Docker fails to honour its promised file
descriptor limit and the fcntl fails.

man fcntl says there are 3 possible causes: negative oldfd (no) max nb file
descriptors already open (no) and oldfd greater than the rlimit (I think that
this is the case).

Here is an example.

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <errno.h>

int main(void)
{
   struct rlimit rlim;
   getrlimit(RLIMIT_NOFILE, &rlim);

   printf("nofile soft limit %ld hard limit %ld\n", (long)rlim.rlim_cur,
(long)rlim.rlim_max);

   for (long i = 4; i <= rlim.rlim_cur; ++i)
   {
      int newFd = fcntl(1, F_DUPFD, i);
      if (newFd != -1)
      {
         close(newFd);
      }
      else
      {
         fprintf(stderr, "default soft limit failed to DUPFD %ld\n", i);
         perror("");
         break;
      }
   }
   rlim.rlim_cur = rlim.rlim_max;
   setrlimit(RLIMIT_NOFILE, &rlim);

   for (long i = 4; i <= rlim.rlim_cur; ++i)
   {
      int newFd = fcntl(1, F_DUPFD, i);
      if (newFd != -1)
      {
         close(newFd);
      }
      else
      {
         fprintf(stderr, "maximum soft limit failed to DUPFD %ld\n", i);
         perror("");
         break;
      }
   }
}

Compiling and running this on RHEL 7.6 I get

nofile soft limit 65535 hard limit 65535
default soft limit failed to DUPFD 65535
Invalid argument
maximum soft limit failed to DUPFD 65535
Invalid argument

Could you try it and report back whether you also see the first failing dup
being equal to the limits?

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to