From 4fb4dffa202bb7a09eb2c0c2784f28eb11137f04 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 18:14:02 +0330 Subject: fix: bytes test read one byte past the fixed map into the heap rt.MW is the end of the fixed map (PW) since the growing heap landed; the heap starts right there, so ld16(addr_b(rt.MW)-1) read the heap's first byte: 0 on the default map by luck, 0x40 on the small map (16384). Probe the real byte-op bound instead: core answers syscall(9,10) with the host reservation MW; micro ports, whose bound is their memory size, fall back to syscall(9,0). --- src/core/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/core.c b/src/core/core.c index 7d1b91e..d758cb6 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -382,6 +382,7 @@ static Cell hostcall(Cell op, Cell a, Cell b, Cell c) } if (a == 7 || a == 8) return stack_expand(a == 8, b, &cb_s, &cb_r); if (a == 9) return code_reserve(b); + if (a == 10) return MW; /* where byte loads and stores stop: the host reservation, not memory_words */ return -1; case 43: { /* clone an isolated execution context with a bidirectional channel */ #if !defined(_WIN32) && !defined(__wasm__) -- cgit v1.2.3