Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger returnValue through unwind context unwinds too far #119

Open
LinqLover opened this issue Mar 3, 2024 · 0 comments
Open

Debugger returnValue through unwind context unwinds too far #119

LinqLover opened this issue Mar 3, 2024 · 0 comments
Labels
base system [SCOPE] Squeak's basic (language) concerns such as Kernel, Collections, Graphics, Network bug [WHAT] Something isn't working as expected. Automated tests beneficial. :- programmer [SCOPE] It is for the (maybe professional) programmer vm simulation [SCOPE] Anything that simulates VM behavior in Squeak such as debugger step.

Comments

@LinqLover
Copy link
Contributor

Steps to reproduce

Do it/print it:

[self error] ensure: [self halt]

In the debugger, yellow-click UndefinedObject>>DoIt (home), choose "return entered value", and enter any value.

Expected: Should land in UndefinedObject(Object)>>halt.
Actual: Land in Compiler>>evaluateCue:ifFail:logged: (but the process suspendedContext is not actually yet there).
Patch:

  Debugger>>returnValue
  	"Force a return of a given value to the previous context!"
  
- 	| previous selectedContext expression value |
+  	| previous selectedContext expression value newContext |
  	contextStackIndex = 0 ifTrue: [^Beeper beep].
  	selectedContext := self selectedContext.
  	expression := UIManager default request: 'Enter expression for return value:'.
  	value := Compiler new 
   				evaluate: expression
  				in: selectedContext
  				to: selectedContext receiver.
  	previous := selectedContext sender.
- 	self resetContext: previous.
- 	interruptedProcess popTo: previous value: value
+ 	newContext := self
+ 		handleLabelUpdatesIn: [interruptedProcess popTo: previous value: value]
+ 		whenExecuting: previous.
+ 	self resetContext: newContext. "might differ from previous in case of error during unwinding"

With that change, let's continue and step out of [] in UndefinedObject>>DoIt. Whether you use step over or step through from UndefinedObject>>DoIt or step into all the details of the unwind stack, in any case the process ends up completely terminated before the debugger halts in Compiler>>evaluateCue:ifFail:logged: as expected, and you get anything like disabled stepping buttons in the debugger, a cannotReturn: error, or a nil DNU from the debugger.

Something seems to be wrong with the unwinding logic here. I checked: This is not a regression and already failed in 6.0 and 5.3.

@isCzech FYIO, just in case you're up for another round of unwinding fun. Otherwise, I might myself address this one day. :-)

@LinqLover LinqLover added programmer [SCOPE] It is for the (maybe professional) programmer base system [SCOPE] Squeak's basic (language) concerns such as Kernel, Collections, Graphics, Network vm simulation [SCOPE] Anything that simulates VM behavior in Squeak such as debugger step. bug [WHAT] Something isn't working as expected. Automated tests beneficial. :- labels Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base system [SCOPE] Squeak's basic (language) concerns such as Kernel, Collections, Graphics, Network bug [WHAT] Something isn't working as expected. Automated tests beneficial. :- programmer [SCOPE] It is for the (maybe professional) programmer vm simulation [SCOPE] Anything that simulates VM behavior in Squeak such as debugger step.
Projects
None yet
Development

No branches or pull requests

1 participant