<br><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 1:29 PM, 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. I am trying to do something and I found a VM crash. Suppose I want to swap out a class, do a become with a proxy (that with the DNU will load the class back). In addition, I have instances of the swapped class.<br>

<br>Example of code (will crash in the last line):<br><br>o := MyObject new.<br>o foo: 123.<br>p := ClassProxy new.<br>p become: MyObject.<br>o == nil.<br>o foo.<br><br><br>My Object just extends Object, has an instVar &#39;foo&#39;,  and implements the accessors. <br>

<br>ClassProxy implements:<br><br>become: aClass<br>    className := aClass name.<br>    aClass fileOut.<br>    super become: aClass<br><br>and<br><br>doesNotUnderstand: aMessage<br>    | reloadedClass |<br>    (FileStream fileNamed: className, &#39;.st&#39;) fileIn.<br>

    reloadedClass := Smalltalk at: className. <br>    self becomeForward: reloadedClass.<br>    ^aMessage sendTo: reloadedClass<br><br><br>So....does someone know why the crash?<br></blockquote><div><br></div><div>I&#39;m not sure but here are some possible reasons...</div>
<div><br></div><div>1. you didn&#39;t flush the method lookup cache after doing the becomeForward: and the perform in sentTo: found a stale method and boom.</div><div>2. you became from a class with N inst vars to one with N+M inst vars and the methods of the new class accessed inst vars &gt; N which are off the end of your instance, causing the VM to read invalid oops and boom.</div>
<div><br></div><div>So a) always flush the method lookup cache and b) /never/ cause the VM to read past an object by changing the class underneath an object such that the class accesses more inst vars than the instance has.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>how can I solve it ?<br><br>Thanks in advance<br>
<br>Mariano<br>
<br></blockquote></div><br>