[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] There is no bound check when marshalling FFI atomic integer arguments (#251)

Nicolas Cellier notifications at github.com
Wed Apr 18 07:37:58 UTC 2018


When marshalling integer values, the value is first extracted from the Smalltalk oop via the method `ffiIntegerValueOf:` .

  - SmallInteger -> SmallInteger value (signed value on 31 or 61 bits on 32bits and 64bits VM)
  - false/true -> 0/1
  - nil -> 0
  - Character -> Character value (may be more than 8 bits long!)
  - LargePositiveInteger -> 32bits positive integer value (or fail) (or 64 bits if ThreadedFFIPlugin)
  - LargeNegativeInteger -> 32bits signed integer value (or fail) (or 64bits if ThreadedFFIPlugin)

Then the value is cast to the expected value in `ffiArgByValue:` which will have the effect of silently masking potential errors...
(`1<<31` could be passed to a signed int and re-interpreted as `-(1<<31)` for example).

IMO we could enforce bound checks and raise an Error...
We should at least do this in the debug version if ever there is a concern about speed (but I don't think so).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/251
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20180418/18ea8ad9/attachment.html>


More information about the Vm-dev mailing list