[squeak-dev] The Inbox: Kernel-nice.1407.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 13 13:34:18 UTC 2021

Nicolas Cellier uploaded a new version of Kernel to project The Inbox:

==================== Summary ====================

Name: Kernel-nice.1407
Author: nice
Time: 13 May 2021, 3:34:15.142602 pm
UUID: c4b8ae2c-02a9-415b-bcf3-6628b8f9f8e7
Ancestors: Kernel-jar.1406

When simulating (for example via the debugger) correctly unwind the simulation machinery #ensure: block inserted by #runUntilErrorOrReturnFrom:

Simulating #aboutToReturn:through: did jump to first unwind context. But this first unwind context was determined BEFORE the simulation #ensure: has been inserted. This had the effect of skipping the simulation machinery protection, and did result in a BlockCannotReturn (cannotReturn:) error...

This did prevent the debugger to correctly debug a protected block with non local return like this:
	[^2] ensure: [Transcript cr; show: 'done'].

Kudos to Jaromir for finding this!

=============== Diff against Kernel-jar.1406 ===============

Item was changed:
  ----- Method: Context>>return:from: (in category 'instruction decoding') -----
  return: value from: aSender 
  	"For simulation.  Roll back self to aSender and return value from it.  Execute any unwind blocks on the way.  ASSUMES aSender is a sender of self"
  	| newTop |
  	aSender isDead ifTrue:
  		[^self send: #cannotReturn: to: self with: {value}].
  	newTop := aSender sender.
  	(self findNextUnwindContextUpTo: newTop) ifNotNil:
+ 		 ^self send: #simulatedAboutToReturn:through: to: self with: {value. unwindProtectCtxt}].
- 		 ^self send: #aboutToReturn:through: to: self with: {value. unwindProtectCtxt}].
  	self releaseTo: newTop.
  	newTop ifNotNil: [newTop push: value].

Item was added:
+ ----- Method: Context>>simulatedAboutToReturn:through: (in category 'private') -----
+ simulatedAboutToReturn: result through: firstUnwindContext 
+ 	"This is the simulated version of #aboutToReturn:through:
+ 	Since the simulation machinery inserts its own ensure: block, we must unwind it first.
+ 	See #runUntilErrorOrReturnFrom:"
+ 	self methodReturnContext
+ 		return: result
+ 		through: ((thisContext findNextUnwindContextUpTo: firstUnwindContext) ifNil: [firstUnwindContext])!

More information about the Squeak-dev mailing list