code wiki / (root) / nx_segv_log_002.nx

nx_segv_log_002.nx source

↩ module page · 31 lines · 2609 B

1// nx_segv_log_002.nx -- incident-002 entry. Tier-swap parses 2// correctly but arithmetic-level overflow proof requires backend 3// work. Per user directive "use our write read etc": pure-NishiLang 4// sys_write entry to specs/segv_log.jsonl. 5 6// nx_safety_envelope: 7// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 8// sil_target: SIL1 9// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 10// verdict: NOT_YET_EVALUATED 11 12import "nx_syscalls.nx" 13import "nx_runtime.nx" 14 15const STDOUT: i64 = 1 16 17func main() -> i64 { 18 let path: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/specs/segv_log.jsonl" as *u8 19 let fd: i64 = __syscall(SYS_OPENAT, AT_FDCWD, path as i64, 0x441, 0x1A4, 0, 0) 20 if fd < 0 { return 1 } 21 22 let line: *u8 = "{\"id\":\"tier-002-2026-05-13\",\"kind\":\"tier_proof_partial\",\"discovered_at\":\"2026-05-13T15:05\",\"symptom\":\"nx_tier_swap_inversion_smoke ran nx_int=i32 successfully but produced same output as nx_int=i64 (no visible overflow)\",\"trigger\":\"type nx_int = i32 swap in nx_tier.nx; compile + run nx_tier_swap_demo.nx\",\"root_cause\":\"parser registers nx_int as i32 Type* correctly (verified via sed grep), but riscv codegen + IR widen i32 arithmetic operands to i64 before emit, so 5e9 sum fits regardless of declared type\",\"evidence\":\"step3-of-inversion-smoke exit=0; rc1=0 rc2=0 instead of expected rc1=0 rc2!=0\",\"fix\":\"future work in nxc2 backend: respect declared width for arithmetic; emit i32 ops (addw/subw/mulw) when both operands are i32. Tracked as compiler issue, NOT a tier-alias defect.\",\"verification\":\"compiler-side: nx_diagram smoke + tier_swap_demo BOTH PASS with refactored nx_diagram.nx using nx_int/nx_idx/nx_size aliases (proves alias parses + struct-field width works). Runtime arithmetic width remains compiler TODO.\",\"files_touched\":[\"nxc2/runtime/nx_diagram.nx\",\"nxc2/runtime/nx_tier.nx\",\"nxc2/bench/nx_tier_swap_demo_smoke.sh\",\"nxc2/bench/nx_tier_swap_inversion_smoke.sh\"],\"regression_test\":\"nx_diagram_smoke.sh + nx_tier_swap_demo_smoke.sh\",\"lesson\":\"Type alias is correct at PARSE layer; width-narrowing at ARITHMETIC layer is a separate backend feature. The discipline is still valuable: layout-level swap (struct field widths) works today; full numeric-tier swap waits on backend respect-declared-width.\"}\n" as *u8 23 24 let n: i64 = strlen(line) 25 sys_write(fd, line, n) 26 sys_close(fd) 27 28 let msg: *u8 = "segv_log.jsonl updated with incident tier-002-2026-05-13\n" as *u8 29 sys_write(STDOUT, msg, strlen(msg)) 30 return 0 31}