> On 11 Feb 2025, at 04:38, Jessica Long <jeslong0...@gmail.com> wrote:
> 
> Not sure what to do. I'm new to Linux and Valgrind. 
> 
> I'm on CLion, and I'm trying to run my code with Valgrind memcheck.  However 
> I get the message. 
> 
> --33110:0:libcfile Valgrind: FATAL: Private file creation failed.
>    The current file descriptor limit is 1073741804.
>    If you are running in Docker please consider
>    lowering this limit with the shell built-in limit command.
> --33110:0:libcfile Exiting now.
> 


Hi

Are you using Docker?

If you are, here is what is happening. Valgrind tries to make itself invisible 
to the rest application that it is testing. Since Valgrind uses some files 
itself (e.g., for the log) it reserves for itself a small number of file 
descriptors. These files will use the highest possible file descriptors. In 
order that this seems (mostly) invisible Valgrind will also change the 
‘resource limit’ for file descriptors ilimit is the API that developers should 
use to query things like file descriptor limits. On a real Linux instance the 
file descriptor limit is something sensible like 65536.

Enter Docker.

Docker screws up the file descriptor limit. For some reason, instead of using 
the same sensible limit that the host is using Docker sets the limit to the 
maximum theoretical limit (possibly by querying the kernel sysctl fs.file-max). 
In your case that is a billion files. So when Valgrind runs it will try to use 
file descriptors up around the 1 billion mark for its own use. When this 
happens the Linux kernel tries to extend the array of structures that it uses 
for files up to the file descriptor that Valgrind has requested. Typically that 
is an infeasibly large amount of memory, and the allocation request will fail. 
Valgrind gets back an error code (ENOMEM - not enough memory) and it terminates 
because it can’t continue without being able to use files.

Solutions

I don’t know if you can tell Docker to use a sensible file descriptor limit.

Otherwise, when you are running a shell inside Docker, before you run CLion, 
enter the command

ulimit -n 65536

(that is for sh and bash, csh has a similar command).

A+
Paul

_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to