Valgrind 3.18 crashes at start in a Docker container whose open-file limit is about 1 billion
Symptom#
In scripts/docker-test.sh gcc12 on a lab-ws VM (Debian trixie host, Docker from the distro), ctest memory_valgrind_planted_leak fails in 0.01 s with ***Exception: SegFault and valgrind: m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit)' failed. The same test passes in the same image under Docker Desktop on macOS.
Cause#
The VM's Docker gives containers ulimit -n 1073741816 (soft and hard). Ubuntu 22.04's Valgrind cannot handle a file limit that high.
Fix#
Set a normal default in /etc/docker/daemon.json: "default-ulimits": {"nofile": {"Name": "nofile", "Soft": 1048576, "Hard": 1048576}}, then sudo systemctl restart docker. Check with docker run --rm IMAGE sh -c 'ulimit -n'. Per run, docker run --ulimit nofile=1048576:1048576 works too.
Evidence#
2026-10-19, workspace dftu-gate on pve: limit 1073741816 before, 1048576 after the daemon change.
Also found by searching
- valgrind: m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit)' failed.
- memory_valgrind_planted_leak segfaults in the gcc12 container on a lab VM
- valgrind crashes at start inside docker