code wiki / _hdl_build / nx_doc_constscan.nx
nx_doc_constscan.nx
buildroot/runtime/_hdl_build/nx_doc_constscan.nx
about
nx_doc_constscan.nx -- static detector for the LM-030 footgun (sibling of nx_doc_ubscan/LM-031): indexing a
`const *T` global DIRECTLY in expression position -- CONST[i] -- silently miscompiles (it crashed nx_cc with a
parser desync historically; today it returns a garbage value, measured: nx_doc_demo_const SM_LIB[2] ran 156 for
expected 99). The fix-by-construction: bind the const to a local first (`let p = CONST; p[i]`) or pass it to a
func that indexes its param. 2-pass: (1) collect every `const NAME: *...` pointer-const name; (2) flag any
`NAME[` direct-index usage (the declaration is `NAME:` so it never matches). LINEAGE: the NISHI RECYCLER's
hardening for the memory-safety/UB critiques (recyc_crit_ub.raw / recyc_crit_memsafety.raw). READ-ONLY. ORIGINAL
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_doc_heal_let.nx
imported by: nx_doc_constscan_gate.nxnx_doc_constscan_run.nx
structs
| none |
consts
| none |
functions
| 11 | func cs_skipws(src: *u8, n: i64, p0: i64) -> i64 called by 1: cs_record |
| 17 | func cs_is_const_at(src: *u8, n: i64, i: i64) -> i64 |
| 29 | func cs_record(src: *u8, n: i64, i: i64, names: *u8, nlens: *i64, ncountp: *i64, capn: i64) -> i64 |
| 49 | func cs_is_const_name(names: *u8, nlens: *i64, ncount: i64, src: *u8, from: i64, len: i64) -> i64 called by 1: cs_scan |
| 58 | func cs_scan(src: *u8, n: i64, outname: *u8, outpos: *i64) -> i64 called by 2: mainmain calls 6: sys_mmapcs_is_const_atcs_recorddhl_isidentdhl_name_atcs_is_const_name |