lumbda/www/repl/asm
russell@unturf.com d672ab077e
wasm asm: read_string handles \" \\ \n \t escapes — bend payload works
The WAT $read_string function scanned bytes until the first " and copied
raw, with NO escape handling. So a source string like
"(\"00\" \"01\")" got chopped at the first \" — the asm tier read only
"(\\" before terminating, producing a mangled payload that the worker
couldn't parse. The bend-gpu demo's payload built via string-append of
escaped-quote strings came out as "(cuda-shake-fanout (\ \ \) 32)" in
the asm tier, sent garbage to bend, and got nothing useful back.

Two-pass fix to match Python/C tier behavior:
  1. Scan-and-count pass: walks source-ptr to the closing ", but
     when it sees \ it skips the next byte so embedded \" doesn't
     terminate the string. Counts decoded output bytes (each \X
     contributes one byte, not two).
  2. Allocate + copy-and-decode pass: walks the same range, converts
     \n → 0x0A, \t → 0x09, and any other \X (including \" and \\)
     → X. Matches the lenient fallback the desktop tiers use.

Verified via cross-tier parity probe — 255/255 still passing.
Demo payload now constructs as
"(cuda-shake-fanout (\"00\" \"01\" \"deadbeef\") 32)" (45 bytes,
identical to Python/C reads) and the asm playground returns
(ok (HEX0 HEX1 HEX2)) from the live 3090-ai bend worker.
2026-06-14 19:00:17 -04:00
..
lumbda-asm.loader.js gc diagnostics: per-tier heap pressure surfaced in repl tabbar 2026-06-14 17:32:48 -04:00
lumbda-asm.wasm wasm asm: read_string handles \" \\ \n \t escapes — bend payload works 2026-06-14 19:00:17 -04:00