Issue 1633: Object allSubInstances appears to loop forever

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 1633: Object allSubInstances appears to loop forever

Stan Shepherd
Pharo image: Pharo | Pharo-core
PharoCore1.0rc1 Latest update: #10502
VM: unix - i686 - linux-gnu - Pharo0.1 of 16 May 2008 [latest update:
#10074]

Steps to reproduce:
1.Object allSubInstances

It appears to be repeatedly adding its current context.

...Stan

OrderedCollection>>addLast:
        Receiver: an OrderedCollection(an Object an Object an Object an
Object an Object an Object an Object...etc...
        Arguments and temporary variables:
                newObject: [] in Object
class(Behavior)>>allSubInstances
        Receiver's instance variables:
                array: an Array(an Object an Object an Object an Object an
Object an Object an ...etc...
                firstIndex: 1
                lastIndex: 1173805

OrderedCollection>>add:
        Receiver: an OrderedCollection(an Object an Object an Object an
Object an Object an Object an Object...etc...
        Arguments and temporary variables:
                newObject: [] in Object
class(Behavior)>>allSubInstances
        Receiver's instance variables:
                array: an Array(an Object an Object an Object an Object an
Object an Object an ...etc...
                firstIndex: 1
                lastIndex: 1173805

[] in Object class(Behavior)>>allSubInstances
        Receiver: Object
        Arguments and temporary variables:
                aCollection: [] in Object
class(Behavior)>>allSubInstances
                x: an OrderedCollection(an Object an Object an Object
an Object an Object an Ob...etc...
        Receiver's instance variables:
                superclass: ProtoObject
                methodDict: a MethodDictionary(size 408)
                format: 2
                instanceVariables: nil
                organization: ('*DynamicBindings' binding binding:
hasBinding removeBinding)
('...etc...
                subclasses: {BalloonState. StandardFileMenuResult.
UndefinedObject. Boolean. Fi...etc...
                name: #Object
                classPool: a Dictionary(#DependentsFields->a
WeakIdentityKeyDictionary(MCWorkin...etc...
                sharedPools: nil
                environment: Smalltalk
                category: #'Kernel-Objects'
                traitComposition: {}
                localSelectors: nil
...
Reply | Threaded
Open this post in threaded view
|

Re: Issue 1633: Object allSubInstances appears to loop forever

Eliot Miranda-2
with closures the block in allSubInstances will be a different object on each evaluation.  Pre closures this would have been a single BlockContext used for each evaluation of the block (and hence non-reentrant).  So you need to modify, e.g. by implementing allInstancesDo: in MethodContext class:

'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 18 December 2009 at 9:26:47 am'!

!MethodContext class methodsFor: 'hacks' stamp: 'ar 9/17/2008 16:24'!
allInstancesDo: aBlock
"Only count until thisContext"
| inst next |
inst := self someInstance.
[inst == thisContext] whileFalse:[
next := inst nextInstance.
aBlock value: inst.
inst := next]! !

find it attached

On Fri, Dec 18, 2009 at 7:47 AM, Stan Shepherd <[hidden email]> wrote:

Pharo image: Pharo | Pharo-core
PharoCore1.0rc1 Latest update: #10502
VM: unix - i686 - linux-gnu - Pharo0.1 of 16 May 2008 [latest update:
#10074]

Steps to reproduce:
1.Object allSubInstances

It appears to be repeatedly adding its current context.

...Stan

OrderedCollection>>addLast:
       Receiver: an OrderedCollection(an Object an Object an Object an
Object an Object an Object an Object...etc...
       Arguments and temporary variables:
               newObject:      [] in Object
class(Behavior)>>allSubInstances
       Receiver's instance variables:
               array:  an Array(an Object an Object an Object an Object an
Object an Object an ...etc...
               firstIndex:     1
               lastIndex:      1173805

OrderedCollection>>add:
       Receiver: an OrderedCollection(an Object an Object an Object an
Object an Object an Object an Object...etc...
       Arguments and temporary variables:
               newObject:      [] in Object
class(Behavior)>>allSubInstances
       Receiver's instance variables:
               array:  an Array(an Object an Object an Object an Object an
Object an Object an ...etc...
               firstIndex:     1
               lastIndex:      1173805

[] in Object class(Behavior)>>allSubInstances
       Receiver: Object
       Arguments and temporary variables:
               aCollection:    [] in Object
class(Behavior)>>allSubInstances
               x:      an OrderedCollection(an Object an Object an Object
an Object an Object an Ob...etc...
       Receiver's instance variables:
               superclass:     ProtoObject
               methodDict:     a MethodDictionary(size 408)
               format:         2
               instanceVariables:      nil
               organization:   ('*DynamicBindings' binding binding:
hasBinding removeBinding)
('...etc...
               subclasses:     {BalloonState. StandardFileMenuResult.
UndefinedObject. Boolean. Fi...etc...
               name:   #Object
               classPool:      a Dictionary(#DependentsFields->a
WeakIdentityKeyDictionary(MCWorkin...etc...
               sharedPools:    nil
               environment:    Smalltalk
               category:       #'Kernel-Objects'
               traitComposition:       {}
               localSelectors:         nil
...
--
View this message in context: http://n2.nabble.com/Issue-1633-Object-allSubInstances-appears-to-loop-forever-tp4187269p4187269.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

MethodContext class-allInstancesDo.st (504 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Issue 1633: Object allSubInstances appears to loop forever

Stéphane Ducasse
thanks eliot

this is strange I thought that we fixed that already .... I have to check.

On Dec 18, 2009, at 6:28 PM, Eliot Miranda wrote:

> with closures the block in allSubInstances will be a different object on each evaluation.  Pre closures this would have been a single BlockContext used for each evaluation of the block (and hence non-reentrant).  So you need to modify, e.g. by implementing allInstancesDo: in MethodContext class:
>
> 'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 18 December 2009 at 9:26:47 am'!
>
> !MethodContext class methodsFor: 'hacks' stamp: 'ar 9/17/2008 16:24'!
> allInstancesDo: aBlock
> "Only count until thisContext"
> | inst next |
> inst := self someInstance.
> [inst == thisContext] whileFalse:[
> next := inst nextInstance.
> aBlock value: inst.
> inst := next]! !
>
> find it attached
>
> On Fri, Dec 18, 2009 at 7:47 AM, Stan Shepherd <[hidden email]> wrote:
>
> Pharo image: Pharo | Pharo-core
> PharoCore1.0rc1 Latest update: #10502
> VM: unix - i686 - linux-gnu - Pharo0.1 of 16 May 2008 [latest update:
> #10074]
>
> Steps to reproduce:
> 1.Object allSubInstances
>
> It appears to be repeatedly adding its current context.
>
> ...Stan
>
> OrderedCollection>>addLast:
>        Receiver: an OrderedCollection(an Object an Object an Object an
> Object an Object an Object an Object...etc...
>        Arguments and temporary variables:
>                newObject:      [] in Object
> class(Behavior)>>allSubInstances
>        Receiver's instance variables:
>                array:  an Array(an Object an Object an Object an Object an
> Object an Object an ...etc...
>                firstIndex:     1
>                lastIndex:      1173805
>
> OrderedCollection>>add:
>        Receiver: an OrderedCollection(an Object an Object an Object an
> Object an Object an Object an Object...etc...
>        Arguments and temporary variables:
>                newObject:      [] in Object
> class(Behavior)>>allSubInstances
>        Receiver's instance variables:
>                array:  an Array(an Object an Object an Object an Object an
> Object an Object an ...etc...
>                firstIndex:     1
>                lastIndex:      1173805
>
> [] in Object class(Behavior)>>allSubInstances
>        Receiver: Object
>        Arguments and temporary variables:
>                aCollection:    [] in Object
> class(Behavior)>>allSubInstances
>                x:      an OrderedCollection(an Object an Object an Object
> an Object an Object an Ob...etc...
>        Receiver's instance variables:
>                superclass:     ProtoObject
>                methodDict:     a MethodDictionary(size 408)
>                format:         2
>                instanceVariables:      nil
>                organization:   ('*DynamicBindings' binding binding:
> hasBinding removeBinding)
> ('...etc...
>                subclasses:     {BalloonState. StandardFileMenuResult.
> UndefinedObject. Boolean. Fi...etc...
>                name:   #Object
>                classPool:      a Dictionary(#DependentsFields->a
> WeakIdentityKeyDictionary(MCWorkin...etc...
>                sharedPools:    nil
>                environment:    Smalltalk
>                category:       #'Kernel-Objects'
>                traitComposition:       {}
>                localSelectors:         nil
> ...
> --
> View this message in context: http://n2.nabble.com/Issue-1633-Object-allSubInstances-appears-to-loop-forever-tp4187269p4187269.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> <MethodContext class-allInstancesDo.st>_______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Issue 1633: Object allSubInstances appears to loop forever

Stan Shepherd

Stéphane Ducasse wrote
thanks eliot

this is strange I thought that we fixed that already .... I have to check.

On Dec 18, 2009, at 6:28 PM, Eliot Miranda wrote:

> with closures the block in allSubInstances will be a different object on each evaluation.  Pre closures this would have been a single BlockContext used for each evaluation of the block (and hence non-reentrant).  So you need to modify, e.g. by implementing allInstancesDo: in MethodContext class:
>
> 'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 18 December 2009 at 9:26:47 am'!
>
> !MethodContext class methodsFor: 'hacks' stamp: 'ar 9/17/2008 16:24'!
> allInstancesDo: aBlock
> "Only count until thisContext"
> | inst next |
> inst := self someInstance.
> [inst == thisContext] whileFalse:[
> next := inst nextInstance.
> aBlock value: inst.
> inst := next]! !
>
> find it attached
>
> On Fri, Dec 18, 2009 at 7:47 AM, Stan Shepherd <stan.shepherd414@gmail.com> wrote:
>
> Pharo image: Pharo | Pharo-core
> PharoCore1.0rc1 Latest update: #10502
> VM: unix - i686 - linux-gnu - Pharo0.1 of 16 May 2008 [latest update:
> #10074]
>
> Steps to reproduce:
> 1.Object allSubInstances
>
> It appears to be repeatedly adding its current context.
>
> ...Stan
>
> OrderedCollection>>addLast:
>        Receiver: an OrderedCollection(an Object an Object an Object an
> Object an Object an Object an Object...etc...

I think the fixed bug was the similar 'Issue 1044: MethodContext allInstances loops forever'. Not quite the same:

'From Pharo1.0beta of 16 May 2008 [Latest update: #10470] on 17 October 2009 at 4:49:35 pm'!

!Behavior methodsFor: 'accessing instances and variables' stamp: 'MarcusDenker 10/17/2009 16:49'!
allInstances
        "Answer a collection of all current instances of the receiver."

        | all inst next |
        all := OrderedCollection new.
        inst := self someInstance.
        [inst == nil]
                whileFalse: [
                next := inst nextInstance.
                inst == all ifFalse: [all add: inst].
                inst := next].
        ^ all asArray! !
Reply | Threaded
Open this post in threaded view
|

Re: Issue 1633: Object allSubInstances appears to loop forever

Stéphane Ducasse
Yes I checked that too.
BTW thanks - this is nice to open a bug tracker entry because like that we do not have open it
just to close it. :)

>>>
> I think the fixed bug was the similar 'Issue 1044: MethodContext
> allInstances loops forever'. Not quite the same:
>
> 'From Pharo1.0beta of 16 May 2008 [Latest update: #10470] on 17 October 2009
> at 4:49:35 pm'!
>
> !Behavior methodsFor: 'accessing instances and variables' stamp:
> 'MarcusDenker 10/17/2009 16:49'!
> allInstances
> "Answer a collection of all current instances of the receiver."
>
> | all inst next |
> all := OrderedCollection new.
> inst := self someInstance.
> [inst == nil]
> whileFalse: [
> next := inst nextInstance.
> inst == all ifFalse: [all add: inst].
> inst := next].
> ^ all asArray! !
>
> --
> View this message in context: http://n2.nabble.com/Issue-1633-Object-allSubInstances-appears-to-loop-forever-tp4187269p4188409.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Issue 1633: Object allSubInstances appears to loop forever

Stan Shepherd
In reply to this post by Eliot Miranda-2

Eliot Miranda-2 wrote
with closures the block in allSubInstances will be a different object on
each evaluation.  Pre closures this would have been a single BlockContext
used for each evaluation of the block (and hence non-reentrant).  So you
need to modify, e.g. by implementing allInstancesDo: in MethodContext class:

'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 18 December
2009 at 9:26:47 am'!

!MethodContext class methodsFor: 'hacks' stamp: 'ar 9/17/2008 16:24'!
allInstancesDo: aBlock
"Only count until thisContext"
| inst next |
inst := self someInstance.
[inst == thisContext] whileFalse:[
next := inst nextInstance.
aBlock value: inst.
inst := next]! !

find it attached

On Fri, Dec 18, 2009 at 7:47 AM, Stan Shepherd
<stan.shepherd414@gmail.com>wrote:

>
> Pharo image: Pharo | Pharo-core
> PharoCore1.0rc1 Latest update: #10502
> VM: unix - i686 - linux-gnu - Pharo0.1 of 16 May 2008 [latest update:
> #10074]
>
> Steps to reproduce:
> 1.Object allSubInstances
>
> It appears to be repeatedly adding its current context.
>
> ...Stan
>
> OrderedCollection>>addLast:
>        Receiver: an OrderedCollection(an Object an Object an Object an
> Object an Object an Object an Object...etc...
>        Arguments and temporary variables:
>                newObject:      [] in Object

> http://n2.nabble.com/Issue-1633-Object-allSubInstances-appears-to-loop-forever-tp4187269p4187269.html
Thanks Eliot, that does catch the looping.
...Stan