

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
9 messages in net.java.dev.jna.usersRe: EXC_BAD_ACCESS Calling method wit...| From | Sent On | Attachments |
|---|---|---|
| Duncan McGregor | Nov 22, 2007 4:34 am | |
| Duncan McGregor | Nov 22, 2007 8:24 am | |
| Timothy Wall | Nov 22, 2007 8:39 am | |
| Duncan McGregor | Nov 22, 2007 10:35 am | |
| Timothy Wall | Nov 22, 2007 1:01 pm | |
| Duncan McGregor | Nov 22, 2007 1:57 pm | |
| Timothy Wall | Nov 22, 2007 3:58 pm | |
| Duncan McGregor | Nov 22, 2007 4:04 pm | |
| Wayne Meissner | Nov 26, 2007 8:07 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: EXC_BAD_ACCESS Calling method with Structure on Mac (long and tortuous, sorry) | Actions... |
|---|---|---|
| From: | Duncan McGregor (dun...@oneeyedmen.com) | |
| Date: | Nov 22, 2007 8:24:04 am | |
| List: | net.java.dev.jna.users | |
OK, answering my own question.
Duncan, you're doing the right thing on the Java side, but the wrong thing on the Objective-C side. That function is designed for calling by the compiler, which knows the size of the struct, and calls different functions depending on the size and architecture.
More explanation is here http://www.cocoabuilder.com/archive/message/cocoa/2006/6/25/166236
Looks like you're going to have to examine the size of that struct and call different methods accordingly.
Hope this helps
Duncan
On Nov 22, 2007 12:34 PM, Duncan McGregor <dun...@oneeyedmen.com> wrote:
Hi, I'm still pursuing my Cocoa bridge, now onto calling methods which return struct, in particular QTTime
I'm calling objc_msgSend_stret(void* stretAddr, id self, SEL op, ...) via my own function to let me debug, viz
OBJC_EXPORT void DELMEobjc_msgSend_stret(void * stretAddr, id self, SEL op, ...) { NSLog(@"DELMEobjc_msgSend_stret function with %p", stretAddr); objc_msgSend_stret(stretAddr, self, op, 0); NSLog(@"exit DELMEobjc_msgSend_stret function with %p", stretAddr); }
In Java I'm mapping this as private interface RococoaLibrary extends Library { void DELMEobjc_msgSend_stret(Pointer stretAddr, ID receiver, ID selector, Object... args); }
and calling with
public static <T extends Structure> T sendReturnsStructure(ID receiver, ID selector, Class<T> returnedType, Object... args) { try { T result = returnedType.newInstance(); rococoaLibrary.DELMEobjc_msgSend_stret(result.getPointer(), receiver, selector, args); return result; } catch (Exception e) { throw new RuntimeException(e); } }
and
sendReturnsStructure(movie.id(), selector("currentTime"), QTTime.class);
Debugging in XCode the invocation of objc_msgSend_stret succeeds, the struct is populated with plausible values as the current time of the movie, the exit log succeeds, but stepping out of the function fails with
2007-11-22 12:13:56.698 java[17539] DELMEobjc_msgSend_stret function with 0x36a560 Current language: auto; currently objective-c 2007-11-22 12:14:02.951 java[17539] exit DELMEobjc_msgSend_stret function with 0x36a560 Invalid memory access of location 00000002 eip=0036a560 Program received signal: "EXC_BAD_ACCESS". Previous frame inner to this frame (corrupt stack?) Previous frame inner to this frame (corrupt stack?)
(out of the debugger the location is 0).
I've built jna with debug, and even though I can see .LCFI1, ffi_call and dispatch on the stack, stepping out blows, suggesting the stack has been corrupted as GDB suggests.
I'm obviously doing something silly on the Java side, please put me out of my misery
Thanks in anticipation
Duncan







