[Vm-dev] [COG] primitiveClosureValue assert is failing with StackVM
(possible BUG in bytecodes!!)
Mariano Martinez Peck
marianopeck at gmail.com
Wed Dec 22 20:03:25 UTC 2010
Hi Eliot. If I compile a StackVM, and I just press the left arrow in a code
pane of a OB windows, in a pharo image, I get an asser that fails:
(oop & 1) 19202
Sorry I bother with these asserts, but I am trying to solve the crashes I
have and I think starting for the asserts is a good idea.
The assert that fails is in primitiveClosureValue() the part:
blockClosure = longAt(GIV(stackPointer) + (GIV(argumentCount) *
BytesPerWord));
/* begin quickFetchInteger:ofObject: */
oop = longAt((blockClosure + BaseHeaderSize) + (ClosureNumArgsIndex <<
ShiftForWord));
assert((oop & 1));
numArgs = (oop >> 1);
if (!(GIV(argumentCount) == numArgs)) {
/* begin primitiveFail */
if (GIV(primFailCode) == 0) {
GIV(primFailCode) = 1;
}
return;
}
numArgs results to be a large number (using #printNum: was 718613205), and
if I try to do a #printOop: I got a " 0x55aa55aa0x55aa55aa is not on the
heap"
Now, of course, the "if (!(GIV(argumentCount) == numArgs)) " fails.
What it is funny is that I did a #printOop: of blockClosure instVar, and
this is what I get: 0x1f59b578: a(n) Association
Association? WTF ? so...I guess something weird is happening. I continue
debugging it..and I noticed that:
- Several classes were called in addition to Association,like Character.
These seems to be compact classes and implement #value and #value: ;)
- Both, #bytecodePrimValue and #bytecodePrimValueWithArg were not calling
#primitiveClosureValue. So, "isBlock" was false...
I tried modifying #bytecodePrimValueWithArg and #bytecodePrimValue this
line:
isBlock := objectMemory is: rcvr instanceOf:
ClassBlockClosurecompactClassIndex: ClassBlockClosureCompactIndex.
to this one:
isBlock := objectMemory is: rcvr instanceOf: (self splObj:
ClassBlockClosure) compactClassIndex: ClassBlockClosureCompactIndex.
WIth this change, at least, the assert doesn't fail anymore. I made progress
(maybe). But still, for normal closures, "isBlock" seems to be false.
So.....all block values are being managed as a normal send ????
Now, I don't understand why ClassBlockClosureCompactIndex is 0. I think
this may be the problem. Why it is not 12? (in Pharo Smalltalk
compactClassesArray at: 12 ->>> BlockClosure.)
I notice that ObjectMemory >> initializeCompactClassIndices does:
ClassBlockClosureCompactIndex := 0 "12". "Prospective. Currently
TranslatedMethod class"
Notice that this ZERO changes the sematic of #is: oop instanceOf: classOop
compactClassIndex: compactClassIndex
called from the #bytecodePrimValue and bytecodePrimValueWithArg
Finally, I changed the mentioned line to this:
isBlock := objectMemory is: rcvr instanceOf: (self splObj:
ClassBlockClosure) compactClassIndex: 12.
and finally, with block closures, it is calling the primitive, and for
Association it doesn't fail the assert. ahh and the image doesn't crash ;)
I don't know if this is a bug, if my solution was ok, nor it impact. Please
let me know.
Cheers
Mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20101222/3fa4437e/attachment.htm
More information about the Vm-dev
mailing list