Problem
Several tree-walker scope transitions save Interpreter.env as a raw pointer, execute arbitrary JavaScript, and restore the raw pointer afterward. A moving collection inside the nested evaluation can relocate the saved environment and make the deferred restore stale.
The audit found candidates in:
- bare Annex B function-declaration block scopes;
withstatement environments;- debugger evaluation state;
- per-iteration
for-in/for-oflexical environments; - switch CaseBlock environments.
This is the same root-discipline class exposed for try/catch/finally in #832, but it is intentionally separate from the synchronous defining-realm wrapper work in #830.
Required fix
- Audit every tree-walker environment save/restore around callback-capable or allocating evaluation.
- Root and reload saved environments across moving collection on normal and abrupt completion.
- Add exact forced-moving witnesses for each distinct scope shape in tree-walker and required-bytecode modes.
- Mirror any affected VM state handling where the bytecode path owns an equivalent raw environment.
- Run focused TSan, full unit, and relevant test262 statement/eval coverage.