Re: --32556:0:libcfile Valgrind: FATAL: Private file creation failed.

Paul Floyd via Valgrind-users <[email protected]> Tue, 11 Feb 2025 07:18:09 +0100
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>
--===============7641710664679778350==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_E2441542-2D1F-4BE7-AAD7-755DA1536349"


--Apple-Mail=_E2441542-2D1F-4BE7-AAD7-755DA1536349
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8



> On 11 Feb 2025, at 04:38, Jessica Long <[email protected]> wrote:
>=20
> Not sure what to do. I'm new to Linux and Valgrind.=20
>=20
> I'm on CLion, and I'm trying to run my code with Valgrind memcheck.  =
However I get the message.=20
>=20
> --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.
>=20


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 =E2=80=98resource limit=E2=80=99 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=E2=80=99t continue without being able to use files.

Solutions

I don=E2=80=99t 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


--Apple-Mail=_E2441542-2D1F-4BE7-AAD7-755DA1536349
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: =
after-white-space;"><br><div><br><blockquote type=3D"cite"><div>On 11 =
Feb 2025, at 04:38, Jessica Long &lt;[email protected]&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><div><div><span =
style=3D"font-family:-apple-system,&quot;helvetica =
neue&quot;;font-size:16px;font-style:normal;font-weight:400;letter-spacing=
:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:1px;text-decoration:none;float:none;display:inline!important;background-=
color:rgba(0,0,0,0);border-color:rgb(49,49,49);color:rgb(49,49,49)">Not =
sure what to do. I'm new to Linux and Valgrind.&nbsp;</span><div =
style=3D"font-family:-apple-system,&quot;helvetica =
neue&quot;;font-size:16px;font-style:normal;font-weight:400;letter-spacing=
:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:1px;text-decoration:none;background-color:rgba(0,0,0,0);border-color:rgb=
(49,49,49);color:rgb(49,49,49)"><br></div><div =
style=3D"font-family:-apple-system,&quot;helvetica =
neue&quot;;font-size:1rem;font-style:normal;font-weight:400;letter-spacing=
:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:1px;text-decoration:none;background-color:rgba(0,0,0,0);border-color:rgb=
(49,49,49);color:rgb(49,49,49)">I'm on CLion, and I'm trying to run my =
code with Valgrind memcheck.&nbsp; However I get the =
message.&nbsp;</div><div =
style=3D"font-family:-apple-system,&quot;helvetica =
neue&quot;;font-size:16px;font-style:normal;font-weight:400;letter-spacing=
:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:1px;text-decoration:none;background-color:rgba(0,0,0,0);border-color:rgb=
(49,49,49);color:rgb(49,49,49)"><br></div><div =
style=3D"font-family:-apple-system,&quot;helvetica =
neue&quot;;font-size:1rem;font-style:normal;font-weight:400;letter-spacing=
:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:1px;text-decoration:none;background-color:rgba(0,0,0,0);border-color:rgb=
(49,49,49);color:rgb(49,49,49)">--33110:0:libcfile Valgrind: FATAL: =
Private file creation failed.<br>&nbsp; &nbsp;The current file =
descriptor limit is 1073741804.<br>&nbsp; &nbsp;If you are running in =
Docker please consider<br>&nbsp; &nbsp;lowering this limit with the =
shell built-in limit command.<br>--33110:0:libcfile Exiting =
now.</div><div style=3D"font-family:-apple-system,&quot;helvetica =
neue&quot;;font-size:1rem;font-style:normal;font-weight:400;letter-spacing=
:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:1px;text-decoration:none;background-color:rgba(0,0,0,0);border-color:rgb=
(49,49,49);color:rgb(49,49,49)" =
dir=3D"auto"><br></div></div></div></blockquote><br></div><div><br></div><=
div><span style=3D"font-size: 14px;">Hi</span></div><div><span =
style=3D"font-size: 14px;"><br></span></div><div><span style=3D"font-size:=
 14px;">Are you using Docker?</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: 14px;">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 =E2=80=98resource limit=E2=80=99 for file =
descriptors&nbsp;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.</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: 14px;">Enter =
Docker.</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: 14px;">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&nbsp;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=E2=80=99t continue without being able to use =
files.</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: =
14px;">Solutions</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: 14px;">I don=E2=80=99=
t know if you can tell Docker to use a sensible file descriptor =
limit.</span></div><div><br></div><div><span style=3D"font-size: =
14px;">Otherwise, when you are running a shell inside Docker, before you =
run CLion, enter the command</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: 14px;">ulimit -n =
65536</span></div><div><span style=3D"font-size: =
14px;"><br></span></div><div><span style=3D"font-size: 14px;">(that is =
for sh and bash, csh has a similar command).</span></div><div><span =
style=3D"font-size: 14px;"><br></span></div><div><span style=3D"font-size:=
 14px;">A+</span></div><div><span style=3D"font-size: =
14px;">Paul</span></div><div><span style=3D"font-size: =
14px;"><br></span></div></body></html>=

--Apple-Mail=_E2441542-2D1F-4BE7-AAD7-755DA1536349--


--===============7641710664679778350==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============7641710664679778350==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

--===============7641710664679778350==--