

![]() | 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: |
7 messages in net.java.dev.jna.usersRe: [jna-users] Finding Access violat...| From | Sent On | Attachments |
|---|---|---|
| Thomas Börkel | May 21, 2008 8:07 am | |
| Timothy Wall | May 22, 2008 1:41 pm | |
| Timothy Wall | May 22, 2008 1:43 pm | |
| Thomas Börkel | May 22, 2008 11:53 pm | |
| Thomas Börkel | May 23, 2008 12:32 am | |
| Timothy Wall | May 23, 2008 6:14 am | |
| Thomas Börkel | May 28, 2008 9:53 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: [jna-users] Finding Access violations | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | May 22, 2008 1:41:27 pm | |
| List: | net.java.dev.jna.users | |
On May 21, 2008, at 11:07 AM, Thomas Börkel wrote:
HI!
I got some crashes SOMETIMES in my program, so I searched for possible programming errors in native code access. To do this, I attached the Visual Studio 2005 debugger, because it prints out Access violations in its output window:
First-chance exception at 0x6d871015 in java.exe: 0xC0000005: Access violation writing location 0x003e0b80. First-chance exception at 0x6d871015 in java.exe: 0xC0000005: Access violation writing location 0x003e0b80. First-chance exception at 0x0091e252 in java.exe: 0xC0000005: Access violation writing location 0x003e0b80.
Problem is, those violations do not happen consistently, so maybe something with heap corruption.
Problem is, I cannot find an error. Maybe I did something wrong that I cannot see.
Any hints would be greatly appreciated.
Thanks!
Thomas
These are the code fragments:
Netapi32 netapi32; TreeSet<String> domainGroups; IntByReference returnedEntries; PointerByReference sortedBuf; Structure[] displayGroups; Netapi32.NET_DISPLAY_GROUP displayGroup; int index, ret, i;
netapi32 = Netapi32.INSTANCE; domainGroups = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); returnedEntries = new IntByReference(); sortedBuf = new PointerByReference(); index = 0;
do { ret = netapi32.NetQueryDisplayInformation(DOMAIN_CONTROLLER_NAME, 3, index, 1000, LMCONS.MAX_PREFERRED_LENGTH, returnedEntries, sortedBuf);
if(ret == WINERROR.NO_ERROR || ret == WINERROR.ERROR_MORE_DATA) { displayGroup = new Netapi32.NET_DISPLAY_GROUP(sortedBuf.getValue()); displayGroups = displayGroup.toArray(returnedEntries.getValue());
for(i = 0; i < returnedEntries.getValue(); i++) { displayGroup = (Netapi32.NET_DISPLAY_GROUP)displayGroups[i]; domainGroups.add(displayGroup.grpi3_name); index = displayGroup.grpi3_next_index; } netapi32.NetApiBufferFree(sortedBuf.getValue());
Here you are freeing native memory without first clearing the Java object which references it. "displayGroup" is depending on the sortedBuf pointer value. You should set displayGroup/displayGroups to null prior to freeing the native memory.
I don't think that's the cause of your access exceptions, though. What does grpi3_next_index do? You seem to have removed its actual usage in the code snippet above.







