1 message in net.java.dev.jna.users[jna-users] Re: JNA crashes on memory...
FromSent OnAttachments
Timothy WallNov 13, 2008 10:00 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:[jna-users] Re: JNA crashes on memory allocation.Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Nov 13, 2008 10:00:18 am
List:net.java.dev.jna.users

Hi Alexander,

On Nov 13, 2008, at 11:39 AM, Alexander Kitaev wrote:

Hello Timothy,

We use JNA 3.0.7 in SVNKit and in particular on Windows to support NTLM authentication. Recently we've received the following bug report from one of SVNKit users (see attached dump).

You may find our code that uses JNA at
http://svn.svnkit.com/repos/svnkit/branches/1.2.x repository, see SVNWinSecurity class.

Do you know what could be the reason for that issue? We're using 3.0.7 version of JNA, does newer version (3.0.9) address it?

Thank you very much for your help and thank you for the great product!

Offhand, no, I don't know the reason for the issue. All issues addressed in each release are indicated in the release notes at
https://jna.dev.java.net/source/browse/*checkout*/jna/trunk/jnalib/release-notes.html . 3.0.6 fixed an issue which would result in prematurely freed memory referenced by a Structure field.

Since the failure is in malloc, which takes a single argument, I would guess that the argument is out of range (though why that would result in a crash instead of a NULL return, I don't know). The call to malloc throws OutOfMemory if malloc returns NULL, so the problem would seem to be internal to malloc.

Now it's possible that structure and/or memory usage has improperly overwritten system headers/boundaries of malloc'ed memory, which in turn causes the malloc crash. Check usage of variable-sized structures or custom-allocated memory.

IntelliJ may or may not include an additional copy of JNA; I'd be sure to remove that as a source of conflict.

BTW, your mappings would be a little cleaner (you can avoid the "W" suffix and WString usage) if you use the w32 API library default options on library load. These set up mappings to use windows ascii or unicode versions based on a system property and automatically map Java String to either char* or wchar_t* as appropriate.