This most likely has to do with translating a Java structure into a
native typedef understood by libffi.
When a structure is passed by value, its native typedef is calculated
in terms of libffi constants. When libffi first encounters the
structure typedef, it replaces the constants with real references to
libffi types.
Are instances of this structure being used on multiple threads?
Maybe the native typedef is being calculated simultaneously by two or
more threads? Come to think of it, the Java FFIType object is
properly synchronized, but the native translation is most likely not.
On Dec 13, 2007, at 10:19 AM, Duncan McGregor wrote:
On 13 Dec 2007, at 14:53, Duncan McGregor wrote:
Caused by: java.lang.IllegalArgumentException: Native call setup
failure: 1
Beginning to answer my own question, now that I've found the native
source again, the 1 is the result of ffi_prep_cif, and looks to be
FFI_BAD_TYPEDEF. What I don't now understand is how sometimes
ffi_prep_cif can succeed, and other times fail. Predictably, it
always seems to succeed when run under the XCode debugger.
Synchronisation? Garbage collection?