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

Ben Coman btc at openinworld.com
Wed Apr 3 16:48:16 UTC 2019

On Wed, 3 Apr 2019 at 22:54, 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?

You haven't said what you've tried.  This looks updated recently...

btw, I see an experimental git repo for VMMaker ...


but this is not what the production VMs are built from.

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):

You are referring this page then...?


Which part of it are you up to?

struct CXCursor {
>         int
>         enum
>         void *ptr[3];
> };
> It's represented as FFIExternalStructure subclass: #CXCursor.

For more context for interested readers, CxCursor definition is shown

In the case of the callback the handle is an instance of
> FFIExternalStructureReferenceHandle with an Alien embedded into it.

Wow, those posts were back in 2016. How time flies. Its vague, but I don't
remember ever seeing class FFIExternalStructureReferenceHandle or Alien
I'll have to freshly re-follow the posts myself to review.

> 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).

I'm not familiar with that part of it.  Hopefully someone else can chime in.
btw, did you do the whole series of post individually, or bulk load the
code from... http://smalltalkhub.com/#!/~BenComan/LibclangPractice

cheers -ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20190404/a4488138/attachment.html>

More information about the Vm-dev mailing list