Skip to content

fix(vm): missing check for thread status after executing hats and typo of stackFrames in retireThread - #687

Open
alexcui03 wants to merge 2 commits into
scratchfoundation:developfrom
alexcui03:fix/685
Open

fix(vm): missing check for thread status after executing hats and typo of stackFrames in retireThread#687
alexcui03 wants to merge 2 commits into
scratchfoundation:developfrom
alexcui03:fix/685

Conversation

@alexcui03

@alexcui03 alexcui03 commented Aug 26, 2026

Copy link
Copy Markdown

Resolves

Resolves #685

  • Typo of thread.stackFrames in Sequencer.retireThread, leading to uncleared stack frames.
  • Thread status should be checked before invoking Thread.goToNextBlock in startHats, since the thread maybe done after calling execute and thead.goToNextBlock() will raise an error if the above typo is fixed.

Proposed Changes

  • Fix typo of thread.stackFrames in Sequencer.retireThread.
  • Check thread status before calling thead.goToNextBlock(). Thread will only go to next block iff it hasn't been done.
  • Allow param of reuseStackForNextBlock to be null in jsdoc.

Reason for Changes

Stackframes is not cleared when thread is retired due to typo error. To fix that typo, thread status must be checked before invoking thread.goToNextBlock() in startHats. Previously, when calling goToNextBlock, thread.stack is empty and thread.stackFrames is not empty, then the following code:

reuseStackForNextBlock (blockId) {
this.stack[this.stack.length - 1] = blockId;
this.stackFrames[this.stackFrames.length - 1].reuse();
}

will execute as normal, since thread.stack[-1] = null; is valid in javascript. It will assign null value to property '-1', and thread.stack.length will keep 0.

Test Coverage

pass vm/integration/stack-click.js

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@alexcui03

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stackframe is not cleared in retireThread

1 participant