scripts/image-fixes/20-ReflectivityOnStackTest.stReflectivityOnStackTest>>testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually, CompiledMethod>>sourceNodeForPC:The test called self skip with a reference to pharo issue 20072. With the skip removed it fails the same way on our VM and on Cog: SubscriptOutOfBounds (index 16) in Context>>computePCForNewMethod:, called from Context>>method:. The defect is in image code, not in either VM. After a metalink is installed, ReflectiveMethod>>compileAST saves the bytecode-to-AST cache of the OLD bytecode layout in the properties of the old CompiledMethod (saveBcToASTCacheWithAST:). Nothing reads that saved cache for pc lookup. CompiledMethod>>sourceNode answers the shared, now recompiled AST, whose own cache describes the NEW bytecodes. So for the old method still on the stack, sourceNodeForPC: gives wrong nodes, and the old CompiledBlock>>ast of both blocks came back as the whole OCMethodNode. Context>>method: matches old blocks to new blocks by comparing these ASTs, so for the suspended block contexts it either found no match or picked the wrong code, and the pc computation then ran off the new bytecodes. The fix adds CompiledMethod>>sourceNodeForPC:, which uses the saved cache of the old layout when the method has one and otherwise calls super. The same file removes the self skip line from the test; the rest of the test body is unchanged and no assertion was weakened. The repaired test passes on both VMs.
| Test | Defect in | State | Cause |
|---|---|---|---|
ReflectivityOnStackTest>>testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually |
image-code | repaired | Old CompiledMethod kept on the stack resolves sourceNodeForPC: through the shared recompiled AST (new bytecode layout) instead of the old-layout cache that ReflectiveMethod>>compileAST saved in the method properties; Context>>method: then cannot map the old blocks to the new ones. The test also had a self skip for pharo issue 20072. |
Regression check: I ran each class on our VM (JIT on) and on Cog, with and without the fix, and counted PASS. All counts are equal with and without the fix. The only difference is ReflectivityOnStackTest, where the fix turns 22 PASS + 1 SKIP into 23 PASS on both VMs. Counts below are ours = Cog. ReflectivityOnStackTest 22+1 SKIP to 23. ReflectiveMethodTest 22. ReflectivityTest 5. ReflectivityControlTest 71. ReflectivityReificationTest 113. MetaLinkTest 10. OCBytecodeToASTCacheTest 17. MethodMapTest 34. CompiledBlockTest 2. ContextTest 19. StepIntoTest 7. StepOverTest 10. RestartTest 3. RecompileTest 3. StepThroughTest 12. OCCacheResetTest 1. DebugPointTest 45. CompiledMethodTest is not in the image (MISSING-CLASS). DebuggerTest is in the image but ran no tests (it printed only DONE). The repaired test was also run 3 times on each VM, each time as a single test through runtest.sh, and passed every time. I did not run ours-nojit, and I did not run the full suite.
Upstream note: Title: Reflectivity: sourceNodeForPC: of an old CompiledMethod uses the AST cache of the new bytecodes; re-enable the test for issue 20072. Description: ReflectiveMethod>>compileAST saves the old-layout bytecode-to-AST cache in the properties of the old CompiledMethod (saveBcToASTCacheWithAST:), but nothing reads it for pc lookup. CompiledMethod>>sourceNode answers the shared recompiled AST, whose cache describes the new bytecodes. For a method that is still on the stack, CompiledBlock>>ast therefore answered the whole OCMethodNode, and Context>>method: (Reflectivity) could not map old blocks to new blocks; computePCForNewMethod: then raised SubscriptOutOfBounds. Fix: CompiledMethod>>sourceNodeForPC: uses the saved cache when the method has one and otherwise calls super. This makes ReflectivityOnStackTest>>testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually pass, so the self skip for issue 20072 is removed. Project: pharo (OpalCompiler-Core or Reflectivity package, plus Reflectivity-Tests). It needs review by the owner before anything is sent upstream.
Last full sweeps of 2026-11-17: iospharo (sweep14-new14) and stock Cog with the Cog changes (sweepcogp14-new10), with all image fixes. "Before" is the state of the test before the repairs. The Stock Cog column has a value only where the record measured stock Cog: "PASS 3 of 3 (repair run)" is the check of each repair on stock Cog v12.0.6 with the fix entry; "-" is not measured separately.
| Test | Before | State | iospharo VM | Patched Cog | Stock Cog |
|---|---|---|---|---|---|
ReflectivityOnStackTest>>testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually | SKIP | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
Run the tests in a Pharo 14 image (build 791). Before the fix they skip, fail or carry the expected-failure mark.
"Run in a Playground of a Pharo 14 image (Do it and print each line)." ((ReflectivityOnStackTest selector: #testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually) run) printString.
testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually | instance messageNode process | self skip. "see https://github.com/pharo-project/pharo/issues/20072" instance := ReflectivityExampleOnStack new. process := [ instance exampleMethodWaitingOnSemaphoreInEmbeddedBlock ] fork. 0.1 seconds wait. "If we install a link after we execute, we expect it to not matter for this test, as the new code will not be executed" messageNode := (ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock) ast sendNodes last parent. link := MetaLink new metaObject: self; selector: #tagExec. messageNode link: link. self assert: messageNode hasMetalink. self assert: (ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock) class equals: ReflectiveMethod. self assert: tag isNil. "make sure to create the compiledMethod" (ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock) compileAndInstallCompiledMethod. (process findContextsForMethod: process suspendedContext homeMethod) do: [ :ctx | ctx method: ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock ]. "here check that the method is on the stack" self assert: process suspendedContext sender sender method selector equals: #exampleMethodWaitingOnSemaphoreInEmbeddedBlock. "process should be running" self deny: process isTerminated. instance continue. 0.1 seconds wait. self assert: process isTerminated. "It got executed!!" self assert: tag notNil
How to apply an entries file: file in 00-header.st and the entries file as one chunk (the iospharo script scripts/gen-image-fixes.py makes that chunk). Each entry checks for the defect first and prints FIXED, ADDED or SKIP. Download 00-header.st.
fix value: #ReflectivityOnStackTest value: #testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually value: [ :s | s includesSubstring: 'self skip' ] value: 'testExecuteWithWaitingWithLinkInstalledInOuterMethodAfterExecutionOfMethodAfterExecutionOfEmbeddedBlockChangeMethodManually | instance messageNode process | instance := ReflectivityExampleOnStack new. process := [ instance exampleMethodWaitingOnSemaphoreInEmbeddedBlock ] fork. 0.1 seconds wait. "If we install a link after we execute, we expect it to not matter for this test, as the new code will not be executed" messageNode := (ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock) ast sendNodes last parent. link := MetaLink new metaObject: self; selector: #tagExec. messageNode link: link. self assert: messageNode hasMetalink. self assert: (ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock) class equals: ReflectiveMethod. self assert: tag isNil. "make sure to create the compiledMethod" (ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock) compileAndInstallCompiledMethod. (process findContextsForMethod: process suspendedContext homeMethod) do: [ :ctx | ctx method: ReflectivityExampleOnStack >> #exampleMethodWaitingOnSemaphoreInEmbeddedBlock ]. "here check that the method is on the stack" self assert: process suspendedContext sender sender method selector equals: #exampleMethodWaitingOnSemaphoreInEmbeddedBlock. "process should be running" self deny: process isTerminated. instance continue. 0.1 seconds wait. self assert: process isTerminated. "It got executed!" self assert: tag notNil'. add value: #CompiledMethod value: #sourceNodeForPC: value: '*Reflectivity' value: 'sourceNodeForPC: aPC "After metalinks were installed the AST of this method describes the NEW bytecodes, but this method still has the OLD ones (it stays on the stack of suspended processes). ReflectiveMethod>>compileAST saved the bytecode-to-AST cache of the OLD layout in the properties of this method: use it." | cache | cache := self propertyAt: self bcToASTCacheKey ifAbsent: [ nil ]. ^ cache ifNil: [ super sourceNodeForPC: aPC ] ifNotNil: [ cache nodeForPC: aPC ]'.
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.