From b96935eb4fa3a3c2a0033ced973c7913b3e68891 Mon Sep 17 00:00:00 2001 From: Max Leske <250711+theseion@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:39:28 +0200 Subject: [PATCH 1/2] fix: make OnlineSourceDebugInfo>>#readVariableNamed:fromContext: work with dead contexts Use `#currentPC` instead of `pc` to access the PC of the context to prevent errors on dead contexts, where `pc` is `nil`. fixes #18718 --- src/DebugInfo-Tests/DebugInfoTest.class.st | 18 ++++++++++++++++++ src/DebugInfo/OnlineSourceDebugInfo.class.st | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/DebugInfo-Tests/DebugInfoTest.class.st b/src/DebugInfo-Tests/DebugInfoTest.class.st index 2772e4aca83..9f6d113bc56 100644 --- a/src/DebugInfo-Tests/DebugInfoTest.class.st +++ b/src/DebugInfo-Tests/DebugInfoTest.class.st @@ -825,6 +825,24 @@ DebugInfoTest >> testReadLocalMethodTemporaryVariable [ equals: contextWithArguments ] +{ #category : 'tests - read variables' } +DebugInfoTest >> testReadLocalMethodTemporaryVariableFromDeadContext [ + + | debugInfo contextWithArguments | + contextWithArguments := thisContext copy + pc: nil; + yourself. + self assert: contextWithArguments isDead. + debugInfo := self newDebugInfoFor: contextWithArguments method. + + self + shouldnt: [ + debugInfo + readVariableNamed: #contextWithArguments + fromContext: contextWithArguments ] + raise: MessageNotUnderstood +] + { #category : 'tests - read variables' } DebugInfoTest >> testReadLocalOptimizedBlockArgumentVariable [ diff --git a/src/DebugInfo/OnlineSourceDebugInfo.class.st b/src/DebugInfo/OnlineSourceDebugInfo.class.st index 1eb93e5eb38..1810d23d0b3 100644 --- a/src/DebugInfo/OnlineSourceDebugInfo.class.st +++ b/src/DebugInfo/OnlineSourceDebugInfo.class.st @@ -250,7 +250,7 @@ OnlineSourceDebugInfo >> rangeForPC: aPC [ { #category : 'api' } OnlineSourceDebugInfo >> readVariableNamed: aName fromContext: aContext [ - ^ (self debugScopeAt: aContext pc) readVariableNamed: aName fromContext: aContext + ^ (self debugScopeAt: aContext currentPC) readVariableNamed: aName fromContext: aContext ] { #category : 'api' } From aa5fd2c4b542a3cc594596e549faca94664f4d7a Mon Sep 17 00:00:00 2001 From: Max Leske <250711+theseion@users.noreply.github.com> Date: Tue, 11 Nov 2025 07:13:21 +0100 Subject: [PATCH 2/2] Apply review suggestions Co-authored-by: Guille Polito --- src/DebugInfo/OnlineSourceDebugInfo.class.st | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DebugInfo/OnlineSourceDebugInfo.class.st b/src/DebugInfo/OnlineSourceDebugInfo.class.st index 1810d23d0b3..b0d400fcb0b 100644 --- a/src/DebugInfo/OnlineSourceDebugInfo.class.st +++ b/src/DebugInfo/OnlineSourceDebugInfo.class.st @@ -250,7 +250,11 @@ OnlineSourceDebugInfo >> rangeForPC: aPC [ { #category : 'api' } OnlineSourceDebugInfo >> readVariableNamed: aName fromContext: aContext [ - ^ (self debugScopeAt: aContext currentPC) readVariableNamed: aName fromContext: aContext + | currentPC | + "If the context is dead (pc = nil) then we really cannot know how to interpret the temp slots, as it could have been killed in any state. + For backwards compatibility, assume that the dead context has all the temps available at the beginning of the method -- i.e., at its initial PC" + currentPC := aContext pc ifNil: [ compiledCode initialPC ]. + ^ (self debugScopeAt: currentPC) readVariableNamed: aName fromContext: aContext ] { #category : 'api' }