A new version of Kernel was added to project The Inbox: http://source.squeak.org/inbox/Kernel-jar.1553.mcz
==================== Summary ====================
Name: Kernel-jar.1553 Author: jar Time: 18 January 2024, 6:52:19.93534 pm UUID: 01bcdbb4-b3b8-ed43-bba0-772c33f3a1f5 Ancestors: Kernel-mt.1551
fix a bug described at https://github.com/squeak-smalltalk/squeak-object-memory/issues/112
Christoph observed disruptions during process terminations at random positions in a heavily multithreded environment.
The root cause has been tracked down to Context>>#contextEnsure. When a process gets terminated at the precise moment in the middle of creating this ensure guard context when the context chain get disconnected from the rest of the senders chain, the unwind procedure during the termination fails - because suspended context's sender chain is disconnected from its tail before jumping back to the tail. The sequence building the ensure guard context is modified to exclude any disconnected state.
=============== Diff against Kernel-mt.1551 ===============
Item was changed: ----- Method: Context class>>contextEnsure: (in category 'special context creation') ----- contextEnsure: block "Create an #ensure: context that is ready to return from executing its receiver. As ctxt is *not* a top context as required by #jump, we need to put a (fake) return value (nil) on its stack. Otherwise, #jump will pop something different from the stack. Concretely, this caused the bug described in [1] (Scenario 1) because the latest stack top was the closure vector {chain}. This closure vector was accidently popped away so that in the final return statement, #pushRemoteTemp:inVectorAt: raised an error subscript bounds (because the next stack item was not variable). Read the linked bug report for more details.
[1] http://forum.world.st/BUG-s-in-Context-control-jump-runUntilErrorOrReturnFro..."
| ctxt chain | ctxt := thisContext. + [chain := thisContext sender. - [chain := thisContext sender cut: ctxt. ctxt push: nil. "fake return value" ctxt jump] ensure: block. "jump above will resume here without unwinding chain" + ^ chain privSender: nil + "nil chain's sender after the jump rather than before to prevent unwind failure during termination, see bug report [2]: + + [2] https://github.com/squeak-smalltalk/squeak-object-memory/issues/112%22! - ^ chain!
squeak-dev@lists.squeakfoundation.org