Repository navigation
fix: reset every field of a pooled frame in JThread.enter again, as a call cut short can leave its frame there dirty - #120
Conversation
… call cut short can leave its frame there dirty
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
There was a problem hiding this comment.
Restores full field reset of pooled frames in JThread.enter: sp, locals, stack, needLock and direct are cleared again on reuse, alongside method, code, pc and lock. This prevents a frame left dirty by a call cut short, such as a JS stack overflow, from leaking spilled state or stale locals into the next direct call at the same pool slot. The direct flag is moved from the pooled factory into enter so every reuse is re-marked direct.
review-bot, model nvidia/nemotron-3.5-super-vl:free, verdict approve
There was a problem hiding this comment.
The change restores full field reset of pooled frames in JThread.enter, resetting sp, locals, stack, needLock, and direct in addition to the existing m, code, pc, and lock. This prevents a frame that returned to the pool with spilled locals from being reused with stale data. The direct = true assignment moves from pooled into enter, which is safe because enter unconditionally sets it for every frame it returns.
review-bot, model nvidia/nemotron-3.5-super-vl:free, verdict approve
What this changes
Since #116,
java/lang/ScopedValue/StressStackOverflow.java#2fails on master: anAbstractMethodErrorfortryClose()Zon an object of the wrong class (ThreadLocalRandom,ScopedValue, the test class), or an internal errorCannot read properties of undefined (reading 'cls')in compiledStressStackOverflow.fibonacci_pad1, where itsopparameter arrives asundefined. #116 madeJThread.enterwrite only the method, bytecode, pc and lock of a pooled frame, assuming every frame left in the pool is clean. Under this test's random stack overflows a frame comes back to the pool with its locals spilled (checked with a temporary assertion inenter: such frames appear inScopedValue.slowGet,ScopedValue.scopedValueCacheandThreadLocalRandomcalls, with no JS error before them). The next direct call through that slot then reads the old frame's locals instead of its own arguments. The dirty frames sit at depth 11,999, at the hard stack limit, and are off the stack. A pooled frame spills and its exit runs one instruction in the interpreter (viaInterpreter). That instruction is a call that overflows the stack, soraiseunwinds the frame and, as it is direct, throws out of the compiled code. The caller'sif(r!==0){t.unpool(cf)...}never runs, and the spilled frame stays in the pool. Resetting inentercovers this, as before #116.enterresets every field again, as it did before #116. Its time saving was never visible above runner noise.Tests
pnpm typecheckpasses. This PR's OpenJDK selection runs everything, includingStressStackOverflow.java, sincesrc/thread.tschanged.