A new version of Kernel was added to project The Inbox: http://source.squeak.org/inbox/Kernel-jar.1552.mcz
==================== Summary ====================
Name: Kernel-jar.1552 Author: jar Time: 17 January 2024, 12:12:05.464149 am UUID: c03919ae-db2f-1842-a906-a917a9fb1821 Ancestors: Kernel-mt.1551
for discussion (Christoph): remove code fragility.
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 moment it's in the middle of inserting this ensure guard context the unwind procedure during the termination fails - precisely because the sender chain is momentarily in a disconnected state before being stitched back. The sequence building the ensure guard is replaced by a manual creation of the context.
This is just a first draft; if this is the right concept, the code will be polished before merging.
=============== 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." - "Create an #ensure: context that is ready to return from executing its receiver. + ^(Context + sender: nil + receiver: nil + method: (BlockClosure>>#ensure:) + arguments: {block}) nextInstruction; nextInstruction; nextInstruction; yourself! - 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 cut: ctxt. - ctxt push: nil. "fake return value" - ctxt jump] ensure: block. - "jump above will resume here without unwinding chain" - ^ chain!
squeak-dev@lists.squeakfoundation.org