[Vm-dev] [Spur] endless recursion in forward become

Eliot Miranda eliot.miranda at gmail.com
Thu Jun 23 14:55:04 UTC 2016


Hi Bert,


> On Jun 23, 2016, at 4:11 AM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> 
>> On Wed, Jun 22, 2016 at 10:15 PM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>>  
>> Hi Bert,
>> Do you have a reproducible case for me to look at?
> 
> Yes, from one email ago:
> 
>         (ByteString new: 20000000) become: (WideString new: 20000000)
> 
>>  The fix I submitted fixes your original case.  But you could try and fix it yourself.  If the become: is two-way and fails with out-of-memory the failure code should ask to grow memory by the sum of the instance byte sizes.
> 
> The failure code in elementsExchangeIdentityWith: asks the memory to grow by a fixed amount and retry:
> 
> 	ec == #'insufficient object memory'
> 		ifTrue: [Smalltalk garbageCollect < 1048576
> 				ifTrue: [Smalltalk growMemoryByAtLeast: 1048576].
> 			^ self elementsExchangeIdentityWith: otherArray].
> 
> After a few repetitions of this there should be enough room.
> 
> The problem is that growMemoryByAtLeast: does not grow the memory, it apparently only assures that the given amount is available. If that is indeed the intention of primitive 180, we should rename it to something like ensureMemoryAtLeastFree:.

That's not true.  growMemoryByAtLeast: does indeed grow memory, but does so by adding a segment.  So you don't get contiguous memory of a size that's the sum of extant free space and the amount grown.  You're only guaranteed to get contiguous memory of the size you grow memory by.  

> 
>>  There us a bytesSzeOfInstance: method (or close) to compute the required space.
> 
> This seems to work, yes:
> 
> 	ec == #'insufficient object memory' ifTrue:
> 		[Smalltalk ensureMemoryAtLeastFree: ({self. otherArray} detectSum:
> 			[:array | array detectSum:
> 				[:obj | obj class byteSizeOfInstanceOfSize: obj basicSize]]).
> 		 ^self elementsExchangeIdentityWith: otherArray].
> 
> Would renaming growMemoryByAtLeast: (and fixing its comment) make sense?

I'll fix growMemoryByAtLeast:'s comment.  But commit the above, provided you use growMemoryByAtLeast:.

> 
> - Bert -
>  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160623/b15c2abb/attachment-0001.htm


More information about the Vm-dev mailing list