Possible explanation for oddity with deleted class

Ross Boylan RossBoylan at stanfordalumni.org
Sun Sep 11 03:24:24 UTC 2005


On Sat, Sep 10, 2005 at 09:14:40AM +0200, Herbert König wrote:
... 
> RB> At http://minnow.cc.gatech.edu/squeak/2176, Herbert König writes
> RB> -----------------------------------------------------
> RB> After refactoring I inadvertedly deleted a class and filed it in again
> RB> from a previous fileout.  After that a method like
> 
> RB>   myMethod
> RB>      | tempVar |
> RB>       tempVar := DeletedAndRestoredClass new.
> RB>       tempVar validMessageToTempVar.
> 
> RB> So here's the theory: when the class was deleted, the compiled methods
...
> RB> So when you filed in the "new" class it became a new object.  The
> RB> compiled methods continued to reference the old one.  So when they
> RB> ran, you got an error.  Both solutions cause recompilation of the
> RB> method in the presence of the new class.
> 
> The nuisance was, that all the pointer chasing and garbage collecting
> shouldn't have left anything referencing the old class.

Garbage collection only clears out unreferenced items, so if anything
references the old class (e.g., compiled methods, instances of that
class) it will remain.  And most of the pointer chasing appears to
limit attention to "regular" objects, and so misses both references in
compiled methods and the implicit reference of instances to their
class.  After more study of the internals, I notice that there are
additional caches of compiled methods, so they may have references as
well.

...
> But then late binding should take care of that in the case of compiled
> methods. I should be able to change the receiver (tempVar in this
> case) of validMessageToTempVar to a different class which also
> responds to validMessage... so the compiled method cannot store a
> pointer to the old deleted class.
> 
Late binding is no help here.  The problem is with
DeletedAndRestoredClass.  In the compiled method, this references the
old class object.  The #new method gets the proper behavior out of
that object (a new instance is created).  Then #validMessageToTempVar
is dispatched, appropriately, to the old class.  The old class no
longer has any methods, so you get the error.  At least, that's my
theory.

Ross



More information about the Squeak-dev mailing list