Skip to content

wasm runtime: post-parse hang — object_get_dynamic repeats indefinitely with identical args after keyword tokenizer enters its outer loop #1037

Description

@proggeramlug

Summary

After working around #1034 (rt.date_get_day) and #1035 (__classDispatch arg padding), the editor's TS-side keyword tokenizer enters its outer per-line loop and hangs. DevTools console shows the runtime's mem_call: object_get_dynamic log line firing on the same array + same index over and over with no termination:

mem_call: object_get_dynamic args: 0,39,40,62,92,126,127,160,203,207,208,248,279,326,330,332,15 base: 65632
  result: 332 bits: 4074c00000000000
mem_call: object_get_dynamic args: 0,39,40,62,92,126,127,160,203,207,208,248,279,326,330,332,15 base: 65632
  result: 332 bits: 4074c00000000000
...

(repeating indefinitely; tab survives but never finishes, no error, no event loop progress.)

Environment

  • Perry: 0.5.1006
  • Target: web (--target web)
  • macOS 26.4 (Darwin 25.4.0)
  • Reproduced compiling @honeide/editor's perry/editor-component.ts. Hang occurs after CompositeEngine.parse(buffer) returns and the keyword scanner begins working on the document. Other targets (macOS, iOS) tokenize the same buffer without issue.

What we know

  • The 17 args to object_get_dynamic look like a fixed array [0, 39, 40, 62, 92, 126, 127, 160, 203, 207, 208, 248, 279, 326, 330, 332] and an index 15. Result 332 matches arr[15].

  • These numbers line up with byte offsets of | separators in the _KWS_TS keyword string in view-model/editor-view-model.ts, suggesting it's _KWS_TS.indexOf(...) or a related lookup inside a loop that never advances.

  • The loop body in core/tokenizer/keyword-syntax-engine.ts:524:

    for (let ki = 0; ki < kws.length; ki++) {
      if (kws[ki] === word) {  }
    }

    …is plain TS that works on every other target. If the ki counter isn't being incremented in the WASM codegen, or kws.length is being re-read as a constant that prevents loop exit, that would explain the observation.

What I haven't done

  • Bisected to a minimal repro independent of the editor — the suspicion is "for-loop with arr[idx] lookups in a class method on --target web" but I haven't proven it standalone. Happy to do this if useful; flagging early in case you recognize the pattern immediately.
  • Run RUST_LOG=trace against perry-codegen-wasm to see what loop ops it emits.

Repro pointer

git clone https://github.com/HoneIDE/editor && cd editor
# Apply rt.date_get_day shim + __classDispatch arg-padding workaround
# (already wired in examples/web/build.ts on the web-architecture branch).
bun run examples/web/build.ts
python3 -m http.server -d examples/web/dist 8765 &
open http://localhost:8765/index.html
# DevTools console will show the repeating object_get_dynamic mem_calls.

If a focused repro would help, I'll reduce the keyword tokenizer to a standalone test case and attach.

Possibly related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions