code wiki / _hdl_build / nx_leakscan_gate.nx

nx_leakscan_gate.nx

buildroot/runtime/_hdl_build/nx_leakscan_gate.nx

10012 B197 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_leakscan_gate.nx -- STANDING DETECTOR for the allocate-without-free class. WHY THIS EXISTS (2026-08-01): two INDEPENDENT runaways collapsed the host in one night -- nx_docportal_admin_daemon (16.5 GB resident in 10 SECONDS, 842 GB of address space over 49h) and nx_ts_lumadiff (28.4 GB, OOM-killed 7 times). Both were found BY HAND, mid-outage, after the control plane had already died and three other instruments reported healthy. Nothing was watching the one signal that named them both instantly. THE SIGNAL: an organ that only ever grows has VmPeak == VmSize. A healthy process that allocates and frees has VmPeak > VmSize, because its peak was higher than where it sits now. That single comparison separated the four real leakers from jellyfin (VmPeak > VmSize, normal churn) on the first pass, with no tuning. ★ IT REPORTS ADDRESS SPACE **AND** RESIDENT, AND RANKS ON RESIDENT. VmSize alone cries wolf: a 842 GB VmSize with 602 MB RSS hurts Committed_AS but not the page cache, while 28 GB RESIDENT is what actually drives swap to zero and puts 78 processes into D state. A count without its classification cries wolf; report both, rank by the one that hurts. EXIT CONTRACT: 0 = no process over the resident budget. 1 = at least one OVER (a fix list, loudly named). 2 = the scan could not measure (refuses to report GREEN when it did not look -- absence of findings and absence of measurement must never render identically). nx_leakscan_gate [rss_budget_mb] default budget 4096 MB expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_leakscan_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main ls_atoi ls_w sys_write ls_n sys_write ↻ sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mmap ↻ ls_read sys_openat_rd sys_read sys_close ls_field sys_exit ↻ gv_ctr sys_mmap ↻ gv_check gv_puts sys_write ↻ gv_verdict gv_note_bare_rate gv_bare_rate gv_at gv_obj_has_n gv_at ↻ gv_puts ↻

structs

none

consts

26const LS_PID_MAX: i64 = 65536 // from /proc/sys/kernel/pid_max class, never a round guess
27const LS_DEFAULT_BUDGET_MB: i64 = 4096

functions

29func ls_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
30func ls_n(v: i64) -> i64 {
called by 1: main calls 2: sys_writesys_mmap
39func ls_read(path: *u8, buf: *u8, cap: i64) -> i64 {
called by 1: main calls 3: sys_openat_rdsys_readsys_close
57func ls_field(buf: *u8, n: i64, key: *u8) -> i64 {
called by 1: main
110func ls_atoi(s: *u8) -> i64 {
called by 1: main
116func main(argc: i64, argv: *i64) -> i64 {