[squeak-dev] problem while rehashing shrinked OrderedDictionary

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Mon Feb 7 20:56:24 UTC 2022


Hi Marcel,

> The CI updates a 2-year old image every day and seems to have to issues.

(assuming you meant "seems to have no issues" :))

I think this is simply because "OrderedDictionary allInstances size" answers 0 in a clean image. But not in various images in the wild, just like mine. :-)

Best,
Christoph

---
Sent from Squeak Inbox Talk

On 2022-02-07T21:07:27+01:00, marcel.taeumel at hpi.de wrote:

> Hi Christoph --
> 
> Thanks for reporting a workaround for this issue. The CI updates a 2-year old image every day and seems to have to issues. Thus, I would not make any changes there.
> 
> Best,
> Marcel
> Am 07.02.2022 17:24:40 schrieb christoph.thiede at student.hpi.uni-potsdam.de <christoph.thiede at student.hpi.uni-potsdam.de>:
> Workaround is to patch these two methods manually when you run into the error during updating your image:
> 
> OrderedDictionary >> growTo: anInteger
> 
>     | newCapacity capacityDifference |
>     super growTo: anInteger.
>     newCapacity := self capacity.
>     capacityDifference := newCapacity - order size.
>     capacityDifference = 0 ifTrue: [ ^self ].
>     order := capacityDifference > 0
>         ifTrue: [ order grownBy: capacityDifference ]
>         ifFalse: [ order first: newCapacity ]
> 
> HashedCollection >> growTo: anInteger
>     "Grow the elements array and reinsert the old elements. Do it even if the size of the array is the same as the argument because this methods is also used to rehash the collection."
>     
>     | oldElements |
>     oldElements := array.
>     array := self arrayType new: anInteger.
>     self noCheckNoGrowFillFrom: oldElements
> 
> And then restart the debugger.
> 
> Best,
> Christoph
> 
> ---
> Sent from Squeak Inbox Talk [https://github.com/hpi-swa-lab/squeak-inbox-talk]
> 
> On 2022-02-07T17:21:02+01:00, christoph.thiede at student.hpi.uni-potsdam.de wrote:
> 
> > Hi all,
> >
> > I just ran into this issue again while updating an older image that I had updated 8 months ago. So this seems to be a regression which effectively breaks our update stream if you were using OrderedDictionaries in older images already. Could - and should - we manipulate the update stream in any way to fix it again? :-)
> >
> > Best,
> > Christoph
> >
> > ---
> > Sent from Squeak Inbox Talk
> >
> > On 2021-11-29T20:18:13+01:00, leves at caesar.elte.hu wrote:
> >
> > > Hi Nicolas,
> > >
> > > On Sun, 28 Nov 2021, Nicolas Cellier wrote:
> > >
> > > > Hi all,
> > > > I got a few hiccups while updating some images.
> > > > One of them occurred while rehashing some OrderedDictionary.
> > > > For some reason, the dictionary was shrinked.
> > > > Unfortunately rehash then tries to grow the 'order' ivar by a negative growSize.
> > > > This causes an errorSubscriptBounds:
> > > >
> > > > To reproduce, simply try:
> > > > ??? OrderedDictionary new compact.
> > >
> > > Thanks. That example made it easy to track down what causes the problem.
> > > Collections-ul.962 should have it fixed.
> > > The ideal solution would be to finally change the order variable to be an
> > > OrderedCollection, so that OrderedDictionary wouldn't have to reimplement
> > > most of the logic.
> > >
> > >
> > > Levente
> > >
> > >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220207/25c4169f/attachment.html>
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220207/cc9dddf0/attachment.html>
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220207/c94d0ef4/attachment.html>


More information about the Squeak-dev mailing list