Skip to main content

Module stack

Module stack 

Source
Expand description

Stack probes: how a test finds the least stack a path needs, and tells a stack overflow from every other way a run can fail.

A thread that overflows its stack takes its whole process with it, so a test that bisects for the least stack runs the path once per size in a child process: this test binary again, running one ignored probe test, with the size in an environment variable (fits, least). Only a stack overflow says a size is too small. Rust’s runtime catches the fault on a thread’s guard page, prints thread '…' has overflowed its stack and aborts the process (SIGABRT). Anything else a child does is no measurement, and fails the test with what happened: a panic (exit code 101), an abort with no overflow report (an allocation that failed), another signal (a SIGSEGV the runtime did not report, so not on a guard page), or a probe that did not run (libtest passes a filter that matches nothing). (Review round 5: three tests read every unsuccessful child as an overflow, so a child killed under memory pressure moved a measurement, and a check made from one could fail, or pass, on a wrong figure.)

A child killed by SIGKILL did not end the probe itself: the OOM killer (or a person) ended it from outside, whatever the probe would have come to. Its run is no measurement, but the probe is the same on the next run, so run runs it again, up to KILLED_RUNS runs in all, and a probe killed on every one of them fails the test, saying so: the rule every test’s child keeps (crate::child). A test then measures what it measures whatever memory the machine has free (review round 7: one kill under memory pressure failed the test).

Owner: package B.

Re-exports§

pub use crate::child::KILLED_RUNS;

Enums§

Probe
What one run of a probe came to.

Constants§

OVERFLOW_REPORT
What Rust’s runtime prints when a thread’s stack overflows.

Functions§

classify
What a child that exited with status, printing stdout and stderr, came to, or what else happened to it.
fits
Whether probe passes with var set to value, and not whether it overflowed a stack (run).
least
The least stack, to 4 KiB, of those up to hi on which fits holds, by bisection: fits is false only for a stack overflow (fits).
run
Runs this test binary’s ignored test probe (its whole path, as --exact matches it) in a child process with var set to value. A child killed by SIGKILL is no measurement, and the probe is run again, up to KILLED_RUNS runs in all (crate::child::output).