[prev in list] [next in list] [prev in thread] [next in thread]
List: squeak-dev
Subject: Re: [squeak-dev] Don't rely on weak reference cleanup for lookup of undeclared references
From: Max Leske <maxleske () gmail ! com>
Date: 2018-05-30 18:17:52
Message-ID: CAEHcf-uNh30E43-fAUBLWEX8ag0G84U8+w=H_+6m1CTQQ7tcYQ () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Eliot,
On 28 May 2018 at 22:03:24, squeak-dev-request@lists.squeakfoundation.org (
squeak-dev-request@lists.squeakfoundation.org) wrote:
Hi Max,
> On May 27, 2018, at 2:44 PM <http://airmail.calendar/2018-05-27 14:44:00
CEST>, Max Leske <maxleske@gmail.com> wrote:
>
> Hi,
>
> Once again, there's a situation in the Fuel test suite that uncovered an
issue. Consider the following script:
>
> Object subclass: #Foo
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Kernel-Classes'.
>
> 10 timesRepeat: [(Smalltalk at: #Foo) rename: #Bar.
> (Smalltalk at: #Bar) rename: #Foo ]
>
> In 5.2-alpha this will open a warning dialog, as at some point one of the
class names will be undeclared. Class>>rename: only checks for an entry in
the undeclared dictionary without considering that the weak references may
not yet have been cleaned up.
>
> I understand that this is not really a realistic real world use-case but
it's still annoying for tests. My current workaround is a forced GC after
*every* test in the entire suite (I use ClassFactoryForTestCase, so class
names may be reused many times over). Luckily, the impact on runtime isn't
too bad.
>
> I'd appreciate it if this could be fixed. I'd be even more happy if I
could be notified of the fix, so that I can remove the workaround again.
Do you have ideas about where the bug lies?
Sort of. In Pharo it seems that when renaming a class, the original class
name is never added to Undeclared while in Squeak it is.
It looks to me, that the problem is that Environment>>unbind: is never
sent. In Environment>>renameClass:from:to: #binding:removedFrom: undeclares
the original class name and #binding:addedTo: adds the new binding to the
environment. But the now undeclared original class name remains undeclared.
The following modification gets rid of the problem:
<snip>
aClass updateMethodBindingsTo: newBinding.
declarations add: newBinding.
self binding: newBinding addedTo: self.
self unbind: oldBinding key. "<---------------------- added"
<snip>
HTH,
Max
>
> Cheers,
> Max
[Attachment #5 (text/html)]
<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body \
style="word-wrap:break-word;line-break:after-white-space"><div id="bloop_customfont" \
style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Hi \
Eliot,</div> <div><br></div><br> <div id="bloop_sign_1527702216635976960" \
class="bloop_sign"> <br></div> <br><p class="airmail_on">On 28 May 2018 at 22:03:24, \
<a href="mailto:squeak-dev-request@lists.squeakfoundation.org">squeak-dev-request@lists.squeakfoundation.org</a> \
(<a href="mailto:squeak-dev-request@lists.squeakfoundation.org">squeak-dev-request@lists.squeakfoundation.org</a>) \
wrote:</p> <div><blockquote type="cite" class="clean_bq" \
style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps: \
normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text- \
transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span><div><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">Hi \
Max,</span><br style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style \
:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:s \
tart;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><a \
href="http://airmail.calendar/2018-05-27 14:44:00 CEST" \
style="font-family:helvetica;font-size:13px;font-style:normal;font-variant-caps:normal \
;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On \
May 27, 2018, at 2:44 PM</a><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">, \
Max Leske <</span><a href="mailto:maxleske@gmail.com" \
style="font-family:helvetica;font-size:13px;font-style:normal;font-variant-caps:normal \
;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">maxleske@gmail.com</a><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
wrote:</span><br style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-sty \
le:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align \
:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
Hi,</span><br style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style: \
normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:st \
art;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
Once again, there's a situation in the Fuel test suite that uncovered an issue. \
Consider the following script:</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
Object subclass: #Foo</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
instanceVariableNames: ''</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
classVariableNames: ''</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
poolDictionaries: ''</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
category: 'Kernel-Classes'.</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
</span><br style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:nor \
mal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start \
;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
10 timesRepeat: [(Smalltalk at: #Foo) rename: #Bar.</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
(Smalltalk at: #Bar) rename: #Foo ]</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
In 5.2-alpha this will open a warning dialog, as at some point one of the class names \
will be undeclared. Class>>rename: only checks for an entry in the undeclared \
dictionary without considering that the weak references may not yet have been cleaned \
up.</span><br style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style: \
normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:st \
art;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
I understand that this is not really a realistic real world use-case but it's \
still annoying for tests. My current workaround is a forced GC after *every* test in \
the entire suite (I use ClassFactoryForTestCase, so class names may be reused many \
times over). Luckily, the impact on runtime isn't too bad.</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">><span \
class="Apple-converted-space"> </span></span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">> \
I'd appreciate it if this could be fixed. I'd be even more happy if I could \
be notified of the fix, so that I can remove the workaround again.</span><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span \
style="color:rgb(0,0,0);font-family:helvetica;font-size:13px;font-style:normal;font-va \
riant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-inden \
t:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">Do \
you have ideas about where the bug \
lies?</span></div></span></blockquote></div><p>Sort of. In Pharo it seems that when \
renaming a class, the original class name is never added to Undeclared while in \
Squeak it is. </p><p>It looks to me, that the problem is that \
Environment>>unbind: is never sent. In Environment>>renameClass:from:to: \
#binding:removedFrom: undeclares the original class name and #binding:addedTo: adds \
the new binding to the environment. But the now undeclared original class name \
remains undeclared. The following modification gets rid of the problem:</p><p><span \
class="Apple-tab-span" style="white-space:pre"> </span><snip></p><p><span \
class="Apple-tab-span" style="white-space:pre"> </span>aClass updateMethodBindingsTo: \
newBinding.</p><p><span class="Apple-tab-span" \
style="white-space:pre"> </span>declarations add: newBinding. </p><p><span \
class="Apple-tab-span" style="white-space:pre"> </span>self binding: newBinding \
addedTo: self.</p><p><span class="Apple-tab-span" \
style="white-space:pre"> </span>self unbind: oldBinding key. \
[Attachment #6 (text/plain)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic