code wiki / (root) / nx_getpid_const_probe.nx

nx_getpid_const_probe.nx source

↩ module page · 18 lines · 1009 B

1// nx_getpid_const_probe.nx -- discriminator for the emit_syscall CONST-PATH bug on getpid(39): 2// same binary, three shapes: (a) literal 39 in a leaf fn, (b) 39 via runtime parameter, 3// (c) literal 39 inline in main. If (a)/(c) differ from (b), the const path mistranslates 39. 4// license_tier: ORIGINAL expect_exit: 0 5import "nx_lib_std.nx" 6const K_MAGIC_2277: i64 = 2277 7 8func cgp() -> i64 { return __syscall(172, 0, 0, 0, 0, 0, 0) } // rv64 getpid=172. This probe -- the STANDING DISCRIMINATOR for this very bug -- was itself written in the broken raw-x86 form: 39 IS an RV64 KEY (umount2) translated to ioctl(16) -> -ENOTTY (debt idx K_MAGIC_2277) 9func vgp(nr: i64) -> i64 { return __syscall(nr, 0, 0, 0, 0, 0, 0) } 10 11func main(argc: i64, argv: *i64) -> i64 { 12 std_puts("const_fn=" as *u8); std_pdec(cgp()) 13 std_puts(" var_fn=" as *u8); std_pdec(vgp(39)) 14 std_puts(" const_inline=" as *u8); std_pdec(__syscall(172, 0, 0, 0, 0, 0, 0)) 15 std_puts("\n" as *u8) 16 sys_exit(0) 17 return 0 18}