Expand description
A cap on the process’s address space: how a test makes the C allocator refuse.
liblzma allocates its dictionary with C’s malloc, which no Rust global
allocator sees, so a crate::counted::Allocator cannot refuse it. A cap
on the address space can (RLIMIT_AS): a mapping, or a brk, that would
take the process past it fails, so malloc returns NULL and liblzma
answers LZMA_MEM_ERROR. The cap is process-wide, so a test sets it only
in a child process (this test binary again, running one ignored probe
test, run), and there only around the call it is about:
cap_above_current caps the soft limit a margin above what the process
maps already, and the Capped it returns puts the soft limit back
when it drops (a process may raise its soft limit up to the hard one).
One arena. glibc gives a thread other than the main one an arena of
its own: a 64 MiB reservation, already mapped (so already under any cap
set later), that it grows into with mprotect. When the mmap of a
large block fails, glibc grows that arena instead, so a block of up to
64 MiB passes the cap (libtest runs each test on a thread of its own).
run starts the child with MALLOC_ARENA_MAX=1: every thread then
takes the main arena, which grows with brk, which the cap refuses too.
A probe also allocates and frees no large block before its cap: glibc
keeps the memory of such a free (a freed mmapped chunk raises its
mmap threshold, and the heap then keeps what is freed below it) and
serves a later block from it, which no cap sees.
Linux only, on x86-64 and 64-bit Arm (whose RLIMIT_AS is 9 and rlim_t
64 bits, as declared here: the crate takes no libc dependency for two
calls). Elsewhere SUPPORTED is false and cap_above_current is
std::io::ErrorKind::Unsupported: a caller says it skipped.
Owner: package C (its codec tests and the TPK’s).
Structs§
- Capped
- The soft address-space limit this process had before a
cap_above_current, put back when it drops.
Constants§
- SUPPORTED
- Whether this target can cap its address space here.
Functions§
- cap_
above_ current - Caps this process’s address space
marginbytes above what it maps now (mapped): an allocation of more thanmarginbytes in one piece then fails, while smaller ones made before it fit. - mapped
- The address space this process maps now, in bytes (
VmSizein/proc/self/status). - run
- Runs this test binary’s ignored test
probe(its whole path, as--exactmatches it) in a child process withvarset tovalue, on one malloc arena (module docs). A child killed bySIGKILLfrom outside is run again, up tocrate::child::KILLED_RUNSruns in all (crate::child::output; review round 8: one kill failed the test).