[Cuis] FFI problem with ExternalAddress

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Cuis] FFI problem with ExternalAddress

Phil B
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?

Thanks,
Phil

Reply | Threaded
Open this post in threaded view
|

Re: [Cuis] FFI problem with ExternalAddress

Andreas.Raab
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
ExternalLibrary).

Cheers,
   - Andreas

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?
>
> Thanks,
> Phil
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [Cuis] FFI problem with ExternalAddress

Juan Vuletich-4
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
> ExternalLibrary).
>
> Cheers,
>   - 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 progress.

Cheers,
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?
>>
>> Thanks,
>> Phil
>>

Reply | Threaded
Open this post in threaded view
|

Re: [Cuis] FFI problem with ExternalAddress

Phil B
In reply to this post by Andreas.Raab
On Feb 16, 2010, at 12:16 PM, 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  
> ExternalLibrary).
>
> Cheers,
>  - Andreas
>

Andreas,

I appreciate your suggestion and it looks like that was the problem  
and solution (those items were nil prior to calling  
recreateSpecialObjectsArray)

Thanks again,
Phil

> 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?
>> Thanks,
>> Phil
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [Cuis] FFI problem with ExternalAddress

Phil B
In reply to this post by Juan Vuletich-4

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  
>> ExternalLibrary).
>>
>> Cheers,
>>  - 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  
> progress.
>

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

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


> Cheers,
> Juan Vuletich
>

Thanks,
Phil

>> 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?
>>>
>>> Thanks,
>>> Phil
>>>
>


Reply | Threaded
Open this post in threaded view
|

Re: [Cuis] FFI problem with ExternalAddress

Juan Vuletich-4
Phil (list) wrote:

>
> On Feb 16, 2010, at 2:14 PM, Juan Vuletich wrote:
>
>>
>>
>> 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 progress.
>>
>
> 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
> issue.

Cool! Please consider making this work available for others to use. I'd
be delighted to host optional packages or code for Cuis just like this.

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

Please email them to me, to avoid abusing squeak-dev. Unless others
prefer public discussion of such details here, I'm ok with that too.

Cheers,
Juan Vuletich

Reply | Threaded
Open this post in threaded view
|

Re[2]: [squeak-dev] Re: [Cuis] FFI problem with ExternalAddress

Herbert König
Hello Juan,

JV> Please email them to me, to avoid abusing squeak-dev. Unless others
JV> prefer public discussion of such details here, I'm ok with that too.

I'd prefer the discussion here.

Cheers,

Herbert                            mailto:[hidden email]