DependentsArray size and subscript is out of bounds
mathieu
mathk.sue at gmail.com
Thu Jul 20 05:49:34 UTC 2006
nicolas cellier a écrit :
> Le Jeudi 20 Juillet 2006 00:38, mathieu a écrit :
>> Hi,
>>
>> It is normal that:
>>
>> (DependentsArray new: 100) size
>>
>> return 0?
>
> Yes
>
>> If yes so why?
>
> DependentsArray count only non nil elements
>
>> And if I do:
>> | o |
>>
>> o := WriteStream on: (DependentsArray new: 100).
>> 1 to: 24 do: [:each | o nextPut: Object new]. "do it sevral time"
>>
>> it raise an error 'subscript is out of bounds: 22' from time to time
>> why?
>
> You cannot do that with DependentsArray.
>
> DependentsArray are weak array: that mean that storing an object into a
> DependentsArray does not prevent it from being garbageCollected.
>
> When an element is garbage collected, corresponding index in DependentsArray
> is replaced by nil.
>
> All is occuring in pastEndPut:
> Since initial size (non nil elements) is zero, then the array is grown to
> size: oldSize + ((oldSize max: 20) min: 1000000)
>
> When no garbageCollection occurs, that works fine (except a new
> DependentsArray is created each time you add an Object).
>
> When a garbage collect occurs, all unreferenced (Object new) are removed from
> the DependentsArray, except one (I do not know who is referencing it, maybe
> the BlockContext...).
>
> Thus you allocate a DependentsArray of size 21 and fail when storing element
> number 22...
>
>> Thx
>> Math
>
> What do you need DependentsArray for?
>
> Nicolas
ok thx :)
In fact this is "used" in SmaCC and raise this error:
======================================================
DependentsArray(Object)>>error:
Receiver: a DependentsArray(<keyword> ")" "]" <binarySymbol> "}" ";"
<period> ">" <name> E O F)
Arguments and temporary variables:
aString: *'subscript is out of bounds: 23'*
Receiver's instance variables:
a DependentsArray(<keyword> ")" "]" <binarySymbol> "}" ";" <period> ">"
<name> E O F)
DependentsArray(Object)>>errorSubscriptBounds:
Receiver: a DependentsArray(<keyword> ")" "]" <binarySymbol> "}" ";"
<period> ">" <name> E O F)
Arguments and temporary variables:
index: 23
Receiver's instance variables:
a DependentsArray(<keyword> ")" "]" <binarySymbol> "}" ";" <period> ">"
<name> E O F)
DependentsArray(Object)>>at:put:
Receiver: a DependentsArray(<keyword> ")" "]" <binarySymbol> "}" ";"
<period> ">" <name> E O F)
Arguments and temporary variables:
index: 23
value:
Receiver's instance variables:
a DependentsArray(<keyword> ")" "]" <binarySymbol> "}" ";" <period> ">"
<name> E O F)
WriteStream>>pastEndPut:
Receiver: <<error during printing>>
Arguments and temporary variables:
anObject:
oldSize: 2
grownCollection: a DependentsArray(<keyword> ")" "]" <binarySymbol>
"}" ";" <pe...etc...
Receiver's instance variables:
collection: a DependentsArray(<keyword> ")" "]" <binarySymbol> "}"
";" <period>...etc...
position: 23
readLimit: 23
writeLimit: 1
--- The full stack ---
DependentsArray(Object)>>error:
DependentsArray(Object)>>errorSubscriptBounds:
DependentsArray(Object)>>at:put:
WriteStream>>pastEndPut:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WriteStream>>nextPut:
[] in DependentsArray>>copyWith: {[:s | self do: [:item | s nextPut:
item]. s nextPut: newElement]}
DependentsArray class(SequenceableCollection class)>>streamContents:
DependentsArray>>copyWith:
DependentsArray(Array)>>copyWithDependent:
SmaCCSymbolSet(Object)>>addDependent:
SmaCCSymbolSet>>addComponent:
SmaCCSymbolSet>>baseOn:
SmaCCSymbolSet class>>basedOn:
SmaCCLR1Item>>moveNext
[] in SmaCCItemSet>>moveOn: {[:each | each nextSymbol == aGrammarSymbol
ifTrue: [anItemSet add: each mo...]}
SmaCCItemSet(Set)>>do:
SmaCCItemSet>>moveOn:
[] in SmaCCGrammarCompiler>>createItemSets {[:each | newState :=
itemSet moveOn: each. newState notEmpty ifTrue: [sh...]}
SortedCollection(OrderedCollection)>>do:
SmaCCGrammarCompiler>>createItemSets
SmaCCGrammarCompiler>>transitionTable
SmaCCGrammarCompiler>>compileTransitionTable
SmaCCGrammarCompiler>>compileParser
SmaCCGrammarCompiler>>createChanges
======================================================
More information about the Squeak-dev
mailing list
|