2 messages in net.java.dev.jna.usersRe: [jna-users] new INPUT().toArray(2...
FromSent OnAttachments
Lei DingMar 5, 2008 7:37 pm 
Timothy WallMar 6, 2008 5:39 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] new INPUT().toArray(2) crashes VM!Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Mar 6, 2008 5:39:23 am
List:net.java.dev.jna.users

On Mar 5, 2008, at 10:37 PM, Lei Ding wrote:

Hello Timothy and all, JNA overall is working grealty for me, but a few times it does crashes VM, like a frequent call of toArray, and maybe even just some random call to user32 functions(frequent and rapid calls). INPUT[] inputs = (INPUT[])new INPUT().toArray(2);

This by itself shouldn't cause any problems. The structure memory is cleared when allocated, so it's not like you'd get random data in the structure, at least when allocated with "new". Are you accessing or calling user32 functions from multiple threads?

I am not sure if there's anythign wrong with this statement. Because this sometimes works for me, sometimes crashes VM. By the way, before creating new INPUT, this method also does VirtuaAlloc and VirtualFree to access other process's window control, not sure if that might affect it.

Here's the VM log:

Current thread (0x003f5c00): JavaThread "main" [_thread_in_native, id=2524, stack(0x008d0000,0x00920000)]

siginfo: ExceptionCode=0xc0000005, reading address 0xfffffff8

Consider where you might have generated that address. Note that it has integer value "-8", which looks like something is trying to access 8 bytes ahead of a null pointer. Are you using any data objects for which the system expects to be able to access something ahead of the actual data pointer (there's an MS string variation that does this)?