Closed LinqLover closed 3 years ago
No sure what's going on, but the implementation of primitiveStringHash
is generated and looks ok:
https://github.com/codefrau/SqueakJS/blob/3538c55eb66355a137554aa218e0ffccc3d7575c/plugins/MiscPrimitivePlugin.js#L544-L574
That primitive looks buggy, because it is called with argCount = 1
so it should pop 2 (string+arg) but actually pops 3.
What does it do in other VMs? Are they using argCount? This was generated many years ago, but I don't think the primitive changed?
OMG this must have been wrong since 2014. I just tried it with
primitiveStringHash(argCount) {
...
interpreterProxy.popthenPush(argCount + 1, hash);
}
and metacello.sar continues installing fine.
However, that means some other generated primitives are likely wrong too 🤔 I have not committed a fix yet.
Thank you for the test case!
So ca63f69 checks the stack after every primitive.
And 4e152a6 fixes an embarrassing number of primitives that left the stack imbalanced or at least did not check argCount
.
Released as 1.0.1.
Great, thanks for fixing! :D
So ca63f69 checks the stack after every primitive.
Out of curiosity, how large is the performance impact of such "assertions in production"? :-)
@LinqLover please use the vm-dev list for this kind of question/discussion. Nobody’s gonna read through closed tickets ;)
I tried to file in this
metacello.sar
in two images,Squeak5.3-19448-32bit.image
and a fresh 64-bit Trunk image. In each case, I get the following error message while the preamble of the SAR file is processed:A closer look at the temporary variables causes confusion:
String>>hashWithInitialHash:
and below,speciesHash
contains the receiverMCMethodDefinition>>hash
,hash
isnil
MCMethodDefinition>>hash
and step over all sends, the error does not occurSet>>scanFor:
), the error occurs againSo, is there a bug in
primitiveStringHash
that probably misaligns the stack variables in any way? Interesting bug ...PS: Please let me know if you can reproduce it.