opensmalltalk-vm icon indicating copy to clipboard operation
opensmalltalk-vm copied to clipboard

Primitive 64 (primitiveStringAtPut) does not fail atomically

Open LinqLover opened this issue 2 years ago • 1 comments

To reproduce, in Squeak, do this:

'aaa' copy tryPrimitive: 64 withArgs: {2. $b asciiValue}; yourself

Expected behavior: The primitive fails, and the string remains aaa. This is also what we are used to from primitive 61 (primitiveAtPut).

Actual behavior: The primitive fails, but the string slot has been changed to Character null.

(By the way, TruffleSqueak and SqueakJS show my expected behavior.)

Maybe there is some clever reasoning behind it, but a primitive that fails should not have any other side effects from my first impression. Is this a bug?

LinqLover avatar May 27 '22 17:05 LinqLover

The issue occurs with ByteString but not WideString, so "'aaa' asWideString tryPrimitive: 64 withArgs: {2. $b asciiValue}; yourself" does not show the problem, but "'aaa' copy tryPrimitive: 64 withArgs: {2. $b asciiValue}; yourself" shows the unexpected modification of the receiver.

Classic squeakvm also shows the expected behavior (the difference possibly related to Character not being immediate in the V3 object memory?).

But Cog VM with V3 image also shows the same problem, so it must not be directly related to V3 versus NewObjectMemory.

dtlewis290 avatar May 27 '22 22:05 dtlewis290