8 messages in net.java.dev.jna.usersRe: [jna-users] Re: "Native call setu...
FromSent OnAttachments
Duncan McGregorDec 13, 2007 6:52 am 
Duncan McGregorDec 13, 2007 7:19 am 
Timothy WallDec 13, 2007 7:41 am 
Timothy WallDec 13, 2007 8:01 am 
Duncan McGregorDec 13, 2007 2:12 pm 
Timothy WallDec 13, 2007 4:14 pm 
Duncan McGregorDec 14, 2007 2:35 am 
Duncan McGregorDec 14, 2007 3:55 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Re: "Native call setup failure" passing struct of struct by valueActions...
From:Timothy Wall (twal@dev.java.net)
Date:Dec 13, 2007 7:41:10 am
List:net.java.dev.jna.users

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?