nx_self_host_load_codegen_repro.nx
buildroot/runtime/nx_self_host_load_codegen_repro.nx
about
nx_self_host_load_codegen_repro.nx -- MINIMAL REPRO for the
self-host codegen bug surfaced by the bootstrap-stability audit
+ fixed-point audit on 2026-05-21.
Bug class: the native x86_64 NishiLang binary (built via the
bootstrap loop from the qemu-RV64 substrate) emits INCORRECT
asm for two specific patterns:
A. return <local-variable>:
Expected: movq <slot>(%rbp), %rax ; ret
Got: movabsq $0, %rax ; ret <-- WRONG: returns 0
B. call <named-function>:
Expected: call sys_mmap (or other name)
Got: call <garbage-bytes-as-string> <-- WRONG: name corrupted
Both fail patterns involve reading from memory that was written
earlier (the stack slot for the local; the name-string buffer
for the function name). Common factor: memory-load codegen
emitted by the substrate-compiled native binary is broken
somehow. The qemu-RV64 substrate emits these patterns CORRECTLY
for user code, so the bug is baked into the native binary
itself by the RV64-qemu compiler when it emits nx_compile_x86.nx
+ nx_opt.nx + nx_x86_64_ctx.nx asm.
This source is itself a TEST PROGRAM (returns expected 18 = 7+11)
AND a self-host-bootstrap regression KAT. When the substrate
codegen bug is fixed:
1. The bash test runs this binary natively, expects exit 18.
2. The bootstrap-stability audit (bench/nx_bootstrap_stability_audit.sh)
passes for nx_u8_load_test.nx etc.
3. The fixed-point audit (bench/nx_self_host_fixed_point_audit.sh)
returns PASS (stage_2.s == stage_3.s).
Until that bug is fixed, this KAT is the SMALLEST repro:
7-line function with two locals + return-sum.
expect_exit: 18
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 44 | func foo() -> i64 called by 1: main |
| 50 | func main() -> i64 calls 1: foo |