[Vm-dev] Alien/FFI issue with large struct passed as value and how to load vmmaker?

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 3 22:50:43 UTC 2019

Hi Holger,

On Wed, Apr 3, 2019 at 7:36 AM Holger Freyther <holger at freyther.de> wrote:

> Hi,
> Sorry if this sounds ignorant but I am not sure how to do this with
> Opensmalltalk VM. How do I get a working VMMaker loaded into a Pharo image
> these days? It was quite simple in the pharo-vm days but now I am not even
> sure where to start looking?
> I want to debug a FFI problem I see with Ben's clang-c bindings. I get a
> callback from C with three arguments and one of them is of type CXCursor
> (it needs to be passed on the stack):
> struct CXCursor {
>         int
>         enum
>         void *ptr[3];
> };
> It's represented as FFIExternalStructure subclass: #CXCursor. In the case
> of the callback the handle is an instance of
> FFIExternalStructureReferenceHandle with an Alien embedded into it.

What is the C signature of the callback function, and what is the source of
the marshaling method in the relevant Callback subclass's signatures
Also, what's the callout's signature and what is the Smalltalk code for the

I am trying to understand if the bug is on handling the callback when the
> CXCursor is created or when trying to push it onto the stack when making a
> call.
> The memory on the stack is turned into an Alien. And
> Alien>>#referenceStructAt:length: doesn't return a ByteArray but the
> FFIExternalStructureReferenceHandle with the Alien in it.
> At the same time I think FFIPlugin>>#ffiPushStructureContentsOf: doesn't
> seem to deal with FFIExternalStructureReferencehandle (or handle being an
> Alien).
> Or do I chase it from the wrong end?

Without the code I can't help, hence my questions above.

best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20190403/2dd93b48/attachment.html>

More information about the Vm-dev mailing list