[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">&gt;<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 &lt;</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">&gt; \
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">&gt;<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">&gt; \
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">&gt;<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">&gt; \
Once again, there&#39;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">&gt;<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">&gt; \
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">&gt; \
instanceVariableNames: &#39;&#39;</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">&gt; \
classVariableNames: &#39;&#39;</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">&gt; \
poolDictionaries: &#39;&#39;</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">&gt; \
category: &#39;Kernel-Classes&#39;.</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">&gt; \
</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">&gt; \
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">&gt; \
(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">&gt;<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">&gt; \
In 5.2-alpha this will open a warning dialog, as at some point one of the class names \
will be undeclared. Class&gt;&gt;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">&gt;<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">&gt; \
I understand that this is not really a realistic real world use-case but it&#39;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&#39;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">&gt;<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">&gt; \
I&#39;d appreciate it if this could be fixed. I&#39;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&gt;&gt;unbind: is never sent. In Environment&gt;&gt;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>&lt;snip&gt;</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