Class subclasses

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

Class subclasses

Florin Mateoc-4
Hi,

I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
the process).

If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
ProtoObject class, although ObjectTracer's superclass is ProtoObject.
This can lead to some funny bugs if you try to write some hierarchy traversing code.

Cheers,
Florin

Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

Eliot Miranda-2
Hi Florin,

    I think I'm correct in thinking you can always submit a proposed fix to inbox, even if you don't have commit privileges to trunk.


On Wed, Jun 11, 2014 at 8:44 PM, Florin Mateoc <[hidden email]> wrote:
Hi,

I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
the process).

If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
ProtoObject class, although ObjectTracer's superclass is ProtoObject.
This can lead to some funny bugs if you try to write some hierarchy traversing code.

Cheers,
Florin




--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

Frank Shearar-3
In reply to this post by Florin Mateoc-4
On 12 June 2014 04:44, Florin Mateoc <[hidden email]> wrote:
> Hi,
>
> I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
> the process).
>
> If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
> ProtoObject class, although ObjectTracer's superclass is ProtoObject.
> This can lead to some funny bugs if you try to write some hierarchy traversing code.

ObjectTracer's superclass is ProtoObject, as you say, but ObjectTracer
class's superclass is indeed Class. (Indeed, ProtoObject class
superclass == Class.)

So I'm not sure I understand the nature of the problem: metaclasses
are usually Class subclasses.

Aren't those funny bugs to do with the (unavoidable) singularity at
the top of both hierarchies?

frank

> Cheers,
> Florin
>

Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

Nicolas Cellier



2014-06-12 19:56 GMT+02:00 Frank Shearar <[hidden email]>:
On 12 June 2014 04:44, Florin Mateoc <[hidden email]> wrote:
> Hi,
>
> I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
> the process).
>
> If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
> ProtoObject class, although ObjectTracer's superclass is ProtoObject.
> This can lead to some funny bugs if you try to write some hierarchy traversing code.

ObjectTracer's superclass is ProtoObject, as you say, but ObjectTracer
class's superclass is indeed Class. (Indeed, ProtoObject class
superclass == Class.)

So I'm not sure I understand the nature of the problem: metaclasses
are usually Class subclasses.


Normally, [B superclass = A ==> (B class superclass = A class)].
This is so that [B class canUnderstand: A class selectors anyOne].

What you have now is that (ObjectTracer class canUnderstand: Object class selectos anyOne) which it should not.

Of course [ObjectTracer class canUnderstand: Object selectors anyOne] is true.
It inherits from Object because a Metaclass is an Object...


Aren't those funny bugs to do with the (unavoidable) singularity at
the top of both hierarchies?

frank

> Cheers,
> Florin
>




Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

Florin Mateoc-4
In reply to this post by Frank Shearar-3
On 6/12/2014 1:56 PM, Frank Shearar wrote:

> On 12 June 2014 04:44, Florin Mateoc <[hidden email]> wrote:
>> Hi,
>>
>> I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
>> the process).
>>
>> If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
>> ProtoObject class, although ObjectTracer's superclass is ProtoObject.
>> This can lead to some funny bugs if you try to write some hierarchy traversing code.
> ObjectTracer's superclass is ProtoObject, as you say, but ObjectTracer
> class's superclass is indeed Class. (Indeed, ProtoObject class
> superclass == Class.)

No, ObjectTracer class' superclass is not Class but ProtoObject class, paralleling its class hierarchy. That's exactly
the problem. Although ObjectTracer class' superclass is not Class, Class claims that ObjectTracer class is a direct
subclass. On the other hand if you evaluate ProtoObject class subclasses it also contains ObjectTracer class (that's a
direct consequence of ObjectTracer being a subclass of ProtoObject, metaclasses don't store their subclasses). So now
you have two different behaviors claiming ObjectTracer class as their direct subclass.
This bug could happen because classes cache their subclasses in an instvar and theoretically that information can become
stale - it even happened in practice in this case.

In general, only nil subclasses have their class side direct Class subclasses.

> So I'm not sure I understand the nature of the problem: metaclasses
> are usually Class subclasses.

But not direct subclasses.

>
> Aren't those funny bugs to do with the (unavoidable) singularity at
> the top of both hierarchies?
>
> frank
>
>> Cheers,
>> Florin
>>
> .
>


Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

Florin Mateoc-4
In reply to this post by Eliot Miranda-2
On 6/12/2014 11:54 AM, Eliot Miranda wrote:
Hi Florin,

    I think I'm correct in thinking you can always submit a proposed fix to inbox, even if you don't have commit privileges to trunk.


On Wed, Jun 11, 2014 at 8:44 PM, Florin Mateoc <[hidden email]> wrote:
Hi,

I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
the process).

If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
ProtoObject class, although ObjectTracer's superclass is ProtoObject.
This can lead to some funny bugs if you try to write some hierarchy traversing code.

Cheers,
Florin




--
best,
Eliot


Hi Eliot,

I thought the fix was obvious - we just need to evaluate "Class removeSubclass: ObjectTracer class" - so other than pointing out the bug, I am not sure what else I should do.

Cheers,
Florin


tty
Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

tty
Pardon the noise, but this is an interesting debug problem.

The only message "class" is on Object.


class
"Primitive. Answer the object which is the receiver's class. Essential. See
Object documentation whatIsAPrimitive."

<primitive: 111>
self primitiveFailed

Looking at CoInterpreterPrimitives up the tree to StackInterpreter class >> initializePrimitiveTable we find primitive 111 maps to


        (111 primitiveClass)

On instance side of StackInterpreter it looks like this.


primitiveClass
| instance |
instance := self stackTop.
self pop: argumentCount+1 thenPush: (objectMemory fetchClassOf: instance)

Now, if I had a brain and/or a clue I would ask myself why this bug happens here.

But, I am very tired, so I will peruse tomorrow.


Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

Bert Freudenberg
On 13.06.2014, at 05:00, gettimothy <[hidden email]> wrote:

Pardon the noise, but this is an interesting debug problem.

The only message "class" is on Object.


class
"Primitive. Answer the object which is the receiver's class. Essential. See
Object documentation whatIsAPrimitive."

<primitive: 111>
self primitiveFailed

Looking at CoInterpreterPrimitives up the tree to StackInterpreter class >> initializePrimitiveTable we find primitive 111 maps to


        (111 primitiveClass)

On instance side of StackInterpreter it looks like this.


primitiveClass
| instance |
instance := self stackTop.
self pop: argumentCount+1 thenPush: (objectMemory fetchClassOf: instance)

Now, if I had a brain and/or a clue I would ask myself why this bug happens here.

But, I am very tired, so I will peruse tomorrow.

This problem is not about a VM bug, or even a code bug. It's just that Florin found an inconsistency in the state of the image. That inconsistency was introduced a couple years ago and survived unnoticed in the image until now. 

It is one of the peculiarities of having a persistent image: some bugs are not even in the code.

- Bert -





smime.p7s (5K) Download Attachment
tty
Reply | Threaded
Open this post in threaded view
|

Re: Class subclasses

tty

 This problem is not about a VM bug, or even a code bug. It's just that Florin found an inconsistency in the state of the image. That inconsistency was introduced a couple years ago and survived unnoticed in the image until now.

It is one of the peculiarities of having a persistent image: some bugs are not even in the code.

- Bert -

Fascinating.

That makes sense.

Analogous to the  way class state can introduce bugs, the image itself has state and can introduce a bug.