8 messages in net.java.dev.jna.usersRe: [jna-users] "Native call setup fa...
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] "Native call setup failure" passing struct of struct by valueActions...
From:Timothy Wall (twal@dev.java.net)
Date:Dec 13, 2007 8:01:18 am
List:net.java.dev.jna.users

Since you get *both* a memory error and an invalid struct typedef, it's possible that something is being prematurely GC'd, or not properly set up.

Look at init_type in dispatch.c, which is where ffi typecodes are translated to real ffi types. If the layout is done improperly it could result in either error.

You might get some mileage by attaching gdb to the java process so that it can catch the invalid access (recompile the native stuff with "make DEBUG=true" or "ant -Ddebug=true" to get better source visibility).

There's a method you can call from gdb that makes the apple VM dump the java stack, google "apple gdb java stack dump" 'cuz I don't remember offhand.

On Dec 13, 2007, at 9:53 AM, Duncan McGregor wrote:

I have a weird intermittent test failure passing QTTimeRange structs to a QTMovie on Mac.

public class QTTimeRange extends Structure implements Structure.ByValue { public QTTime time; public QTTime duration;

public class QTTime extends Structure implements Structure.ByValue { public long timeValue; public int timeScale; public int flags;

The calling code says

movie.setSelection(new QTTimeRange(new QTTime(50, 1000), new QTTime (750, 1000)));

which maps onto a call to objc_msgSend(ID, SEL, ...)

Some of the time the call succeeds, sometimes I get E_BAD_ACCESS of varying locations, and sometimes I get an exception

Caused by: java.lang.IllegalArgumentException: Native call setup failure: 1 at com.sun.jna.Function.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:301) at com.sun.jna.Function.invoke(Function.java:236) at com.sun.jna.LibraryHandler.invoke(LibraryHandler.java:132) at $Proxy2.objc_msgSend(Unknown Source)

The QTTimeRange always looks like this

2:37:36 PM Foundation.send - calling objc_msgSend([ID 0x36c100], [Selector setSelection:], org.rococoa.quicktime.QTTimeRange(Native Allocated Memory <0x367f00> (32 bytes)) class org.rococoa.quicktime.QTTime time@0=org.rococoa.quicktime.QTTime(Native Allocated Memory <0x3911e0> (16 bytes)) long timeValue@0=50 int timeScale@8=1000 int flags@c=0 memory dump [00000000] [00000000] [00000000] [00000000] class org.rococoa.quicktime.QTTime duration@10=org.rococoa.quicktime.QTTime(Native Allocated Memory <0x3875c0> (16 bytes)) long timeValue@0=750 int timeScale@8=1000 int flags@c=0 memory dump [00000000] [00000000] [00000000] [00000000] memory dump [00000000] [00000000] [00000000] [00000000] [00000000] [00000000] [00000000] [00000000])

I had thought that the movie might not be fully loaded, but waiting doesn't seem to change anything. Is there any likely cause of "Native call setup failure: 1"?

Thanks

Duncan (Currently mourning the passing of Quicktime for Java, RIP :-(