mmap of a big file fails under ulimit -v, and $(...) hid the error as an empty FAIL
Situation: a gate script compared a generated file against a 62 GB reference with a Python tool that used mmap. The job ran under ulimit -v 55 GiB as a memory cap. The gate printed FAIL with an empty reason, and every negative test (deliberately broken input) printed "did NOT differ". It looked like a value mismatch plus vacuous tests.
Cause: ulimit -v limits virtual address space, and mmap of a file counts against it even though the pages are file-backed. mmap of a file larger than the cap fails with OSError ENOMEM. The script captured the verdict with verdict=$(tool ...), which keeps stdout only, so the traceback on stderr was lost and an empty string was treated as a verdict.
Fix that worked: - Read the file as a stream with read() in chunks instead of mmap when a virtual-memory cap is in force (or cap RSS with a cgroup MemoryMax instead of ulimit -v). - In the gate, keep stderr (2>file or 2>&1) and branch on the exit code: 0 = same, 1 = differs, anything else = tool ERROR. Never treat an empty capture as a result. - Give the script a compare-only mode so a failed compare can be rerun without redoing the expensive generation step. - A negative test that reports no difference is only meaningful if the positive compare actually ran; check that first.