code wiki / _hdl_build / _ad_dupguard_test.nx

_ad_dupguard_test.nx

buildroot/runtime/_hdl_build/_ad_dupguard_test.nx

2475 B40 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic ad
docsdependenciesstructsconstsfunctions

about

_ad_dupguard_test.nx -- the REUSABLE bug-reproduction gate for the daemon dup-guard bug (two daemons coexisted 2026-06-13 because the old pidfile+/proc check was non-atomic). THE CAPABILITY (partner-built with the team): reproduce the bug CLASS first, then prove the fix. Here: a SECOND acquirer of the held single-instance lock MUST be rejected. Parent acquires ad_acquire_lock; a forked child attempts the SAME lock and MUST fail. With the racy old guard this could not be asserted; with the atomic flock it is deterministic (no timing). GREEN = the guard bites. This gate is the template the team reuses for any concurrency/single-instance bug. Imports ONLY nx_ad_core (re-exports nx_syscalls + ad_acquire_lock; a 2nd direct nx_syscalls import is the documented NXASM rc=6 landmine). license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_ad_core.nx _ad_dupguard_test.nx

imports: nx_ad_core.nx

imported by: nobody (leaf or entry point)

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

main ad_acquire_lock g_w sys_fork sys_wait4

structs

none

consts

none

functions

13func g_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
14func g_wn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
16func main() -> i64