New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect literal Character encoding/decoding in SistaV1 bytecode set #618
Comments
Note that restricting |
I think both image and VM have to be fixed. This was a slip by me; apologies. Clearly, the bytecode is wrongly specified. Instead of taking the signed extension B it should take the unsigned extension A. This was a copy-paste error copying the push integer bytecode. So instead of |
I think it's safe to just make the change. The extended form isn't in use in a VMMaker image (trunk + a lot of other stuff) so it won't affect most people. Marcel will be affected but he can update to a new VM (right Marcel)? Here's code that checks: Note that the change is unfortunate. Because the existing VM doesn't clear extA afterwards setting extA can have disastrous effects in the old VM. e.g. if followed by a block creation bytecode then that bytecode will consume the extension not cleared by the push character bytecode. But as I said it is unlikely to bite anyone. Fingers crossed. Hacking the existing spec to use a sign extension is less harmful in the short term, but more harmful in the long term. |
I shall make the new VM take either extA or extB and clear them both, at least temporarily. We can then change the image code to use extA, and hope that no-one is affected, because Marcel, you can upgrade to a new VM and Nicolas, your fix to avoid the use of the bytecode will save us for now. |
🎉 |
As reported by Marcel on Squeak-dev, this snippet:
will return a Character with a negative value (-32768).
This is because character literal in the range 16r100-16rFFFF are encoded with an extended B bytecode, and the extended B is interpreted as signed value.
I suggested
(extB bitAnd: 16rFF) << 8
to reconstruct an unsigned Character valueSee https://source.squeak.org/VMMakerInbox/VMMaker.oscog-nice.3174.diff for the former solution.
The later solution require more changes and a careful recompilation of CompiledMethods at image side.
The text was updated successfully, but these errors were encountered: