nx_chain_selfref_adversary.nx
buildroot/runtime/nx_chain_selfref_adversary.nx
about
nx_chain_selfref_adversary.nx -- T10 class: the SELF-REFERENTIAL chain-fusion
miscompile. A loop-carried alloca updated by `z = z OP (z OP' c)` (BOTH
operands read z) was chain-fused IN PLACE: the inner (z OP' c) mutated z's
home register, so the outer OP read the destroyed z. Symptom: `z = z & (z-1)`
(Brian Kernighan bit-clear) degraded to `z = z - 1` (decrement) -> popcount of
0xFF returned 255 not 8 -> nx_hw_cpu_count popcounted a 16-bit CPU mask to 510
-> every auto-sized thread pool spawned 510 workers (32x oversubscription).
Fixed by the chain-scan guard: a chain step's src must not read the chained
alloca. This adversary is the regression witness; exit 0 == all correct.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 1 imports · 0 importers
imports: nx_syscalls_x86_64.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
| 12 | const K_MAGIC_65535: i64 = 65535 |
| 13 | const K_MAGIC_1024: i64 = 1024 |
functions
| 16 | func popcount(x: i64) -> i64 called by 1: main |
| 23 | func popcount_swapped(x: i64) -> i64 called by 1: main |
| 31 | func xor_lowmask(x: i64) -> i64 called by 1: main |
| 37 | func and_plus1(x: i64) -> i64 called by 1: main |
| 43 | func main() -> i64 |