From 39b55fe1b41aec167295eccc1927255082642ab2 Mon Sep 17 00:00:00 2001 From: Paul DeBruicker Date: Sun, 2 Aug 2026 12:46:19 -0400 Subject: [PATCH] Add an #identityHash check to prevent the recursive image lockup thats possible with current #hash implementation --- src/Collections-Abstract/Collection.class.st | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Collections-Abstract/Collection.class.st b/src/Collections-Abstract/Collection.class.st index 1cc1d3da71c..3e92a5a44f0 100644 --- a/src/Collections-Abstract/Collection.class.st +++ b/src/Collections-Abstract/Collection.class.st @@ -891,11 +891,17 @@ Collection >> hash [ -- two equal objects have equal hash values" | hash | - hash := self species hash. - self size <= 10 ifTrue: - [self do: [:elem | hash := hash bitXor: elem hash]]. - ^hash bitXor: self size hash + self size <= 10 ifTrue: [ + | identity elemIdentityHash elemHash | + identity := self identityHash. + self do: [ :elem | + elemIdentityHash := elem identityHash. + elemHash := elemIdentityHash = identity + ifTrue: [ elemIdentityHash ] + ifFalse: [ elem hash ]. + hash := hash bitXor: elemHash ] ]. + ^ hash bitXor: self size hash ] { #category : 'testing' }