[Vm-dev] FFI Plugin | Auto-conversion of char* return value into String considered harmful

Marcel Taeumel marcel.taeumel at hpi.de
Wed Jun 10 13:14:05 UTC 2020


Hi all,

I just found out that you can avoid this automatic interpretation as C string if you use a type alias to char*. This could at least help if an external library forgets the NULL character for that returned char* and makes your VM crash. :-)

Best,
Marcel
Am 10.06.2020 12:35:27 schrieb Marcel Taeumel <marcel.taeumel at hpi.de>:
Hi all!

The FFI plugin automatically converts "char*" return values into a Smalltalk string when returning from the FFI call.

I would rather leave this conversion to the image side because you have to do it anyway when interpreting external structures. See ExternalData >> #fromCString. And because it can be dangerous. Note that I do like automatic String-to-char* conversion when making an FFI call. Just not the other way around.

See (Threaded)FFIPlugin >> #ffiReturnCStringFrom:.

What are your thoughts on this matter?

Best,
Marcel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20200610/3a9cf69f/attachment.html>


More information about the Vm-dev mailing list