Hi Mariano,<br><br><div class="gmail_quote">On Fri, Dec 3, 2010 at 6:41 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 <br>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.<br>In the mark phase of the GC, it tries to mark all interpreter oops in the method:  markAndTraceInterpreterOops<br>

<br>If you see that method....it does this (a part of it):<br><br>compilerInitialized<br>        ifTrue: [self markAndTrace: receiver.<br>           <span style="background-color:rgb(255, 255, 51)"> self markAndTrace: method]</span><br>

        ifFalse: [self markAndTrace: activeContext].<br>    self markAndTrace: messageSelector.<br>   <span style="background-color:rgb(255, 255, 0)"> self markAndTrace: newMethod.</span><br><br>If you are using SmallInteger as methods.....newMethod can be a SmallIneteger, and not a method....so if we then see the method markAndTrace:<br>

<br>the first lines are:<br><br>    | header lastFieldOffset action statMarkCountLocal |<br>    header := self longAt: oop.<br><br><br>And of course, it crash in that #longAt:<br><br>:)<br><br>So, solutions:<br><br>1) Put an if in each place where it uses newMethod or method or newNativeMethod or suspendedMethods  or whatever<br>

2) Put an if in #markAndSweep.<br><br>I think 2) is easier and it is just adding one line of code at the beginning:<br><br>    | header lastFieldOffset action statMarkCountLocal |<br>  <span style="background-color:rgb(255, 255, 0)">  (self isIntegerObject: oop) ifTrue: [ ^ 0 ].</span><br>

    header := self longAt: oop.<br>....<br><br>what do you think ?<br></blockquote><div><br></div><div>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.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">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.<br>

So maybe there still pending future possible crashes?<br></blockquote><div><br></div><div>We live and learn :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>Thanks<br><br>Mariano<br></blockquote><div><br></div><div>Welcome to the vm community.  You&#39;re doing it now!!</div><div><br></div><div>best</div><div>Eliot </div></div>