[Vm-dev] SmallInetger as methods was not ready yet....now maybe?

Eliot Miranda eliot.miranda at gmail.com
Sat Dec 4 00:10:15 UTC 2010


Hi Mariano,

On Fri, Dec 3, 2010 at 6:41 AM, Mariano Martinez Peck <marianopeck at gmail.com
> wrote:

>
> Hi folks. After fighting and fighting about crashes using SmallInteger as
> methods, I finally could debug the VM (thanks Esteban for the help in
> compiling and debugging!!) and I think I found a problem in theGC.
> In the mark phase of the GC, it tries to mark all interpreter oops in the
> method:  markAndTraceInterpreterOops
>
> If you see that method....it does this (a part of it):
>
> compilerInitialized
>         ifTrue: [self markAndTrace: receiver.
>             self markAndTrace: method]
>         ifFalse: [self markAndTrace: activeContext].
>     self markAndTrace: messageSelector.
>     self markAndTrace: newMethod.
>
> If you are using SmallInteger as methods.....newMethod can be a
> SmallIneteger, and not a method....so if we then see the method
> markAndTrace:
>
> the first lines are:
>
>     | header lastFieldOffset action statMarkCountLocal |
>     header := self longAt: oop.
>
>
> And of course, it crash in that #longAt:
>
> :)
>
> So, solutions:
>
> 1) Put an if in each place where it uses newMethod or method or
> newNativeMethod or suspendedMethods  or whatever
> 2) Put an if in #markAndSweep.
>
> I think 2) is easier and it is just adding one line of code at the
> beginning:
>
>     | header lastFieldOffset action statMarkCountLocal |
>     (self isIntegerObject: oop) ifTrue: [ ^ 0 ].
>     header := self longAt: oop.
> ....
>
> what do you think ?
>

Either.  But if you go with 1) you should put an assert in markAndSweep:.
 The current VM style seems to be to go with 1, although I agree that 2 is
the better approach.

Finally, I am afraid that there are more places where Interpreter uses any
> of those instVar that represent methods, and treat them as real objects.
> So maybe there still pending future possible crashes?
>

We live and learn :)


>
> Thanks
>
> Mariano
>

Welcome to the vm community.  You're doing it now!!

best
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20101203/73de860c/attachment.htm


More information about the Vm-dev mailing list