Skip to main content

enter_alloc_failure_hook

Function enter_alloc_failure_hook 

Source
pub fn enter_alloc_failure_hook()
Expand description

The first call of a binary’s allocation-failure hook. The hook then runs alone and without allocating: it writes its line (write_stderr_unlocked), sweeps the run’s trees (try_remove_registered_paths) and ends the process (exit_now).

When memory is spent, anything the hook allocates fails as well and calls the hook again, on the same thread. Run again, it would allocate again: a fleet child printed 6,048 nested Fatal:oom:alloc_failed lines in a millisecond (each re-entry failing at reading RUST_BACKTRACE, 1 byte). Or it would wait forever. The old hook formatted a backtrace while holding the standard library’s backtrace lock and the stderr lock. Symbolizing the backtrace allocated, the re-entered hook waited on the backtrace lock, and the watchdog’s own Fatal:timeout waited on stderr. The child stayed parked until the harness killed it as unresponsive and re-leased its paper (run 351, 2026-10-14; 1804.07640 among the papers). So a re-entry on the same thread ends the process at once. An allocation failure on another thread meanwhile waits for the first thread’s exit, and exits itself if that has not come in ten seconds.