Pharo test defects

FreeType cache: a race on the lazy FreeType face

State
Open: no fix
Defect in
the Pharo image or the test (not proven)
Tests
2
Fix
none
Upstream repository
pharo-project/pharo

Summary

Pharo 14 arm64: our VM failed 11 of 50 runs, stock Cog 9 of 50 runs. Pharo 13 shows it too. The records name a race in the image on the lazy FreeType face. Both tests pass in the 6 saved sweeps of 2026-11-17. No fix exists. The rule of the project counts a test that fails at times as a test that fails.

Test

"Run in a Playground of a Pharo 14 image (Do it and print each line)."
((FreeTypeCacheTest selector: #testGlyphAccessIsThreadSafe) run) printString.
((FreeTypeCacheTest selector: #testGlyphAccessIsThreadSafeWhenAskingWidth) run) printString.
FreeTypeCacheTest>>testGlyphAccessIsThreadSafe
testGlyphAccessIsThreadSafe
	"This test is weak because it depends in the rendering of Morphic and Rubrik"
	"This test breaks 95% of times"

	self timeLimit: 20 seconds.

	10 timesRepeat: [
		 | sem text canvases blocky |

		sem := Semaphore new.
		text := (String loremIpsum: 25*1024).
		FreeTypeCache current removeAll.
		canvases := OrderedCollection new.

		blocky := [  | canvas |
			canvas := FormCanvas extent: 1000@1000.
			canvases add: canvas.
			(RubScrolledTextMorph new)
					setText: text;
					font: StandardFonts codeFont;
					bounds: (0@0 corner: canvas form extent);
					fullDrawOn: canvas.
			sem signal ].

		blocky forkAt: 39.
		blocky forkAt: 39.
		blocky forkAt: 39.

		sem
			wait;
			wait;
			wait.

		self assert: (((canvases at:1) form bits = (canvases at:2) form bits) and: [ ((canvases at:2) form bits = (canvases at:3) form bits) ])
	]
FreeTypeCacheTest>>testGlyphAccessIsThreadSafeWhenAskingWidth
testGlyphAccessIsThreadSafeWhenAskingWidth
	"This test is weak because it depends in the rendering of Morphic and Rubrik"
	"This test breaks 95% of times"

	self timeLimit: 20 seconds.

	10 timesRepeat: [
		 | sem text canvases blocky widthAsk |

		sem := Semaphore new.
		text := (String loremIpsum: 25*1024).
		FreeTypeCache current removeAll.
		canvases := OrderedCollection new.

		widthAsk := [
			1 to: text size do: [ :i | StandardFonts codeFont widthOf: (text at: i). i % 50 = 0 ifTrue: [ Processor yield ]].
			sem signal ].


		blocky := [  | canvas |
			canvas := FormCanvas extent: 1000@1000.
			canvases add: canvas.
			(RubScrolledTextMorph new)
					setText: text;
					font: StandardFonts codeFont;
					bounds: (0@0 corner: canvas form extent);
					fullDrawOn: canvas.
			sem signal ].

		blocky forkAt: 39.
		blocky forkAt: 39.
		blocky forkAt: 39.
		widthAsk forkAt: 39.

		sem
			wait;
			wait;
			wait;
			wait.

		self assert: (((canvases at:1) form bits = (canvases at:2) form bits) and: [ ((canvases at:2) form bits = (canvases at:3) form bits) ])
	]

Fix

None yet.

State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.