[squeak-dev] Re: [Cuis] FFI problem with ExternalAddress
pbpublist at gmail.com
Tue Feb 16 20:20:25 UTC 2010
On Feb 16, 2010, at 2:14 PM, Juan Vuletich wrote:
> Andreas Raab wrote:
>> Hi Phil -
>> The only thing that comes to mind is the special objects array. Try
>> executing "Smalltalk recreateSpecialObjectsArray" to ensure it is
>> initialized correctly, if that doesn't help check (Smalltalk
>> specialObjectsArray copyFrom: 44 to: 48) which should say
>> #(ExternalAddress ExternalStructure ExternalData ExternalFunction
>> - Andreas
> Thanks for answering Andreas. Just for the record: in
> #recreateSpecialObjectsArray Cuis includes the classes you say, but
> with #at:ifAbsent: , as they are usually not present. So, evaluating
> Smalltalk recreateSpecialObjectsArray should do it.
> Phil, I believe you are the first to try FFI on Cuis. It is good to
> know that it is almost running! Please keep us posted on your
First! :-) Seriously, I've been really enjoying working with Cuis and
the thought you've put into what is, and is not, in it. The good news
is that I've got some basic OpenGL immediate mode code working
(validating at least the function call portion of FFI) and now I'm
working on retained mode which is where I ran into the external memory
I'm starting to assemble a list of a few fixes and minor issues I've
been running into in a variety of areas (mostly trivial fixes: a minor
missing method here and there, modifying a couple of lines of code in
an existing method, etc.) as I'd guess that I'm exercising a lot of
functionality that is probably not mainstream.... do you have any
preference on how you'd like things like that proposed/communicated?
(i.e. post to this list for discussion, email you changesets w/ notes,
or by some other means?)
> Juan Vuletich
>> Phil (list) wrote:
>>> I'm not sure whether my problem is specific to Cuis or is more
>>> generally related to installing FFI. I've loaded FFI (from FFI-
>>> Kernel-ar9) by extracting the archive, filing in the extracted .st
>>> file, and in a workspace executing:
>>> (Smalltalk at: #ExternalType) initialize.
>>> (Smalltalk at: #ExternalStructure) compileAllFields.
>>> FFI appears to be working at least somewhat (i.e. I'm able to make
>>> basic OpenGL calls which are behaving as expected) but when I
>>> attempt to work with externally allocated memory, I'm having
>>> problems. With the following example:
>>> extern := ExternalAddress allocate: 12.
>>> I observe the following behavior:
>>> 1) Do it executes without error
>>> 2) Most things that attempt to look at the result (i.e. print it)
>>> crash the image
>>> 3) extern class returns CompiledMethod
>>> 4) Accessing it with what should be valid indexes using byteAt:
>>> and byteAt:put: either result in an invalid index error or crashes
>>> the image.
>>> The VM I'm using is 4.2.2 on OS X and I'm not able to reproduce
>>> the behavior in any of my non-Cuis images and am curious if
>>> there's an installation/configuration step I've missed re: FFI or
>>> if there is a bug specific to Cuis that might be causing this issue?
More information about the Squeak-dev