squeak-smalltalk / squeak-object-memory

Issues and assets related to the Squeak object memory.
https://bugs.squeak.org
MIT License
11 stars 1 forks source link

ReferenceStream does not rehash HashedCollections during read, which leads to corrupt dictionaries (Solution included) #113

Open unique75m opened 5 months ago

unique75m commented 5 months ago

If you file out dictionaries with the ReferenceStream protocol, restart the image and read the dictionaries back into image from file, then it could be that the hashed keys inside the dictionary are not valid anymore. In my case I have an IdentityDictionary, where the keys are symbols. If this dictionary is read back, then I can see in the Explore-Inspector, that it is corrupted. If I add the same symbol key again, then it is added under a new hash index and added twice, which leads to much more trouble in later computations. I have researched that issue now and I guess there is a simple #rehash missing in method

Object >> readDataFrom:size:

I simply added a "self rehash" before the last return statement and everything works fine now for me. I have tested this with Squeak 6.0