TurboWarp / scratch-vm

Scratch VM with a JIT compiler and more features
https://turbowarp.org/
Mozilla Public License 2.0
75 stars 72 forks source link

Custom reporters can hang browser in certain situations. #201

Closed Wowfunhappy closed 6 months ago

Wowfunhappy commented 6 months ago

I was testing some code when my browser tab completely froze. After some experimentation, I narrowed it down to the following minimal reproduction:

Expected Behavior

This code should do nothing in both the interpreter and compiler.

Screen Shot 2024-03-28 at 11 30 11 AM

I've attached this code as an sb3 file: turbowarp freeze.sb3.zip

Actual Behavior

When the compiler is disabled and the above code is run, TurboWarp completely locks up! Pressing reload brings up a "page unresponsive" dialog in Chrome.

Steps to Reproduce

The problem appears to occur any time the compiler is disabled and:

  1. The result of a custom reporter is passed to another custom block as a parameter.
  2. The second custom block reaches a stop this script or return block.

Operating System and Browser

macOS, Chromium 121.

GarboMuffin commented 6 months ago

Looks like what's happening is frozen StackFrame state isn't being saved through thread.stopThisScript(). Same bug surfaces in vanilla Scratch in less-critical ways. Will try to get that fixed this weekend.

Wowfunhappy commented 6 months ago

Thank you!