squeak-smalltalk / squeak-object-memory

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

`ClassDescription>>#updateInstancesFrom:` is not proxy-safe #46

Open LinqLover opened 2 years ago

LinqLover commented 2 years ago

Given a subclass of ProtoObject that overrides doesNotUnderstand: and/or implements instVarAt:[put:] in a different/faulty way, ClassDescription>>#newInstanceFrom:variable:size:map: via ClassDescription>>#updateInstancesFrom: will fail to update the instances when recompiling the class (or one of its superclasses). Should we use mirror primitives here?

LinqLover commented 2 years ago

And here is an interesting follow-up error that took me too much time to debug: When loading an update of the definition of a proxy class via Monticello, an error from newInstanceFrom:variable:size:map: was not displayed but instead caught via MCPackageLoader>>#basicLoad where that definition was added to errorDefinitions instead and then was retried later. In the second attempt, because the class format already had been updated, no further error occurred, but the class hierarchy was in a corrupt state then because subclasses had not been updated yet (resulting in a subclass of my proxy having a smaller instSize than its superclass). So what's wrong here? Should ClassBuilder>>#mutate:to: have kind of transactional semantics or work in two phases (first change all definitions, then convert all instances)? Or should the error handler from MCPackageLoader be more precise here? What was this error handler for after all? Was it only for detecting missing classes?