<br><br><div class="gmail_quote">On Mon, Jan 30, 2012 at 5:05 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">
Hi guys. I am doing some hacky things and I have a problem. I am sure it is not VM&#39;s fault but mine. I would just like to understand what could be happening.<br><br>Scenario: I have developed an &quot;object graph swapper&quot; which basically takes a graph, and replaces each object of the graph by a proxy. Then the graph is serialized and swapped out to a file. The proxies then intercept messages and materialize from file, and replaces proxies with the materialized objects. When I am swapping out, after I become original objects to proxies, the only reachable proxies are the proxies for the roots and for objects inside the graph which were also referenced from outside the graph. All the rest of the proxies (for objects only reachable from inside the graph) can be garbage collected without problem.<br>





<br>Problem: I am swapping out several graphs one after another one. If after swapping out each graph, I do a GC, then I have no problem. I can swap lots of graphs. However, if I start to swap several graphs but I do not run a gc after each graph, then I have a crash in the VM. The crash happens when becoming original objects to proxies. More precisely it crashes in:<br>





<br>remappedObj: forwardedObj<br>    &quot;Answer the given forwardedOop&#39;s target value<br>     during a compaction or become: operation.&quot;<br>    | fwdBlock targetObj |<br>    &lt;inline: true&gt;<br>    fwdBlock := self forwardingPointerOf: forwardedObj.<br>





    self assert: (self fwdBlockValid: fwdBlock).<br>    targetObj := self longAt: fwdBlock.<br>    self assert: (self addressCouldBeObjWhileForwarding: targetObj).<br>    ^targetObj<br><br>line  targetObj := self longAt: fwdBlock.<br>





it seems fwdBlock has a negative value (I debugged the VM and checked its value) and then the longAt:   gives EXC_BAD_ACCESS.<br><br>My question is, can you imagine something that could be causing the crash?  I would like to understand what is happening. Maybe I am becoming objects which are not reachable anymore and that fails?<br>





Any hint is really appreciated. <br><br>Some investigations: sometimes it fails, but sometimes it works (I think this is because on when the GC runs). It seems that when it breaks, in #remapFieldsAndClassOf:   the oop is a CompiledMethod and so the fieldOffset is the last literal, that is the assocation to the class. Since I also replace classes with proxies, such association has a ClassProxy in its value. Such class contains the 3 intsVars superclass, methodDict and format so that not to crash VM. Format is set with ClassProxy format.   <br>

More information is that it doesn&#39;t crash in StackVM... moreover, it doesn&#39;t crash if I DO NOT create proxies for CompiledMethod .... looks like something with them ... So.... can this give you a hint?<br>


<br></blockquote><div><br><br>Doing some more debugging, it always failing updatePointersInRangeFromto  and always the same reason. The OOP is always a compiled method and fails in the same place. After looking a bit, the final cause is that fwdBlock1 is incorrect...but it is incorrect because of previous other incorrect variables:<br>
<br>fwdBlock1 -&gt; fieldOop -&gt; fieldOffset -&gt; numLiterals -&gt; headerPointer  <br><br>So from what I can see in:<br><br>    /* begin literalCountOfHeader: */<br>            /* begin headerOf: */<br>            methodHeader = longAt((oop + BaseHeaderSize) + (HeaderIndex &lt;&lt; ShiftForWord));<br>
            headerPointer = (isCogMethodReference(methodHeader)<br>                ? (assert(((((CogMethod *) methodHeader)-&gt;objectHeader)) == (nullHeaderForMachineCodeMethod())),<br>                    (((CogMethod *) methodHeader)-&gt;methodHeader))<br>
                : methodHeader);<br>            numLiterals = (((usqInt) headerPointer) &gt;&gt; 10) &amp; 255;<br><br>it looks like if the oop is correct, but headerPointer finishes with an incorrect (negative) value. This is return by #rawHeaderOf:<br>
So...to sum up, I have a compiled method which seems to have its header corrumpted. <br><br>If with this piece of data, together with what I mentioned in the first email, you have a hint, please tell me :)<br><br>Thanks<br>
 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks<span class="HOEnZb"><font color="#888888"><br><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>