[squeak-dev] ObjectAsMethodWrapper >> #uninstall breaks class organisation

Frank Shearar frank.shearar at gmail.com
Thu Aug 23 17:13:34 UTC 2012


On 23 August 2012 18:09, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> On 2012-08-23, at 19:04, Frank Shearar wrote:
>
>> On 23 August 2012 17:35, Bert Freudenberg <bert at freudenbergs.de> wrote:
>>> On 2012-08-23, at 15:07, Frank Shearar wrote:
>>>
>>>> So the organizer loses the reference because ObjectAsMethodWrapper
>>>> calls #removeSelectorSilently:, which eventually calls
>>>> ClassDescription >> #removeSelector:. It re-adds the now-unwrapped
>>>> CompiledMethod to the method dictionary with #addSelector:withMethod:
>>>> which eventually calls ClassDescription >>
>>>> #basicAddSelector:withMethod:. However, this does _not_ add the
>>>> selector to the organization's elementArray, and Bad Things Happen.
>>>
>>>
>>> Why is removing necessary in the first place? Couldn't it just replace the compiled method?
>>
>> Sure, you could. What I think of the canonical example of this stuff
>> is TestCoverage, and it just does
>>
>> TestCoverage >> uninstall
>>       reference actualClass methodDictionary
>>               at: reference methodSymbol
>>               put: method
>>
>> (I'd rather use addSelector:withMethod: than this approach - I don't
>> think it's an ObjectAsMethodWrapper's business to tinker directly with
>> something else's method dictionary.)
>>
>> frank
>
>
> But at least this one would be atomic. Removing followed by adding puts the system into a potentially broken state while the wrapper is already gone but the original method is not yet installed.

Sure: both addSelector:withMethod: and hacking the MD directly, and
either's better than my previous bugfix.

In fact the existing uninstall implementation's semantically
incorrect: we don't want to make an object forget how to handle a
message, but simply alter the existing implementation (by removing the
wrapper).

And adding races to globally accessible structures is never a good idea!

frank

> - Bert -
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ObjectAsMethodWrapper-fbs.20.mcz
Type: application/octet-stream
Size: 6603 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120823/dd19035d/ObjectAsMethodWrapper-fbs.20.obj


More information about the Squeak-dev mailing list