javac#crashjava-access-bridge

Java Access Bridge crashes JVM on releaseJavaObject()


I'm using the Java Access Bridge to pull data from an Oracle interface, and occasionally get the following crash (I'm assuming when I call releaseJavaObject() - as when I remove these lines of code, the problem goes away.

Here's the crash log:

# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d9104dd, pid=7784, tid=5868
#
# JRE version: 6.0_14-b08
# Java VM: Java HotSpot(TM) Client VM (14.0-b16 mixed mode, sharing windows-x86 )
# Problematic frame:
# V  [jvm.dll+0x1104dd]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x04036000):  JavaThread "Thread-5" [_thread_in_vm, id=5868, stack(0x046e0000,0x04730000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000001

Registers:
EAX=0x00000001, EBX=0x23ec7730, ECX=0x00000000, EDX=0x00227c98
ESP=0x0472f504, EBP=0x0472f510, ESI=0x007a0128, EDI=0x04026b8c
EIP=0x6d9104dd, EFLAGS=0x00010202

Top of Stack: (sp=0x0472f504)
0x0472f504:   04026b8c 00227c98 04036000 0472f524
0x0472f514:   6d9105a9 23ec7730 23ec7730 04026f54
0x0472f524:   0472f54c 6d8f1dca 04026b8c 04036000
0x0472f534:   04036110 2bfbf9a0 04036000 00000000
0x0472f544:   0472f534 0472f56c 0472f578 6d0717bd
0x0472f554:   04036110 0472f588 04036000 23ec7b88
0x0472f564:   2bfbf9a0 0472f55c 0472f798 6d0bded0
0x0472f574:   00000000 0472f598 01ef6fc3 04036110 

Instructions: (pc=0x6d9104dd)
0x6d9104cd:   00 00 5e 89 18 5b 5d c2 04 00 8b 86 90 00 00 00
0x6d9104dd:   8b 08 5f 89 8e 90 00 00 00 5e 89 18 5b 5d c2 04 


Stack: [0x046e0000,0x04730000],  sp=0x0472f504,  free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x1104dd]
V  [jvm.dll+0x1105a9]
V  [jvm.dll+0xf1dca]
C  [awt.dll+0x717bd]
J  sun.awt.windows.WComponentPeer.getLocationOnScreen()Ljava/awt/Point;
J  java.awt.Component.getLocationOnScreen_NoTreeLock()Ljava/awt/Point;
J  java.awt.Component.getLocationOnScreen()Ljava/awt/Point;
j  oracle.ewt.lwAWT.LWDataSourceList$Child.getLocationOnScreen()Ljava/awt/Point;+4
J  com.sun.java.accessibility.AccessBridge.getAccessibleBoundsOnScreenFromContext(Ljavax/accessibility/AccessibleContext;)Ljava/awt/Rectangle;
j  com.sun.java.accessibility.AccessBridge.getAccessibleXcoordFromContext(Ljavax/accessibility/AccessibleContext;)I+6
v  ~StubRoutines::call_stub
V  [jvm.dll+0xecabc]
V  [jvm.dll+0x173d61]
V  [jvm.dll+0xecb3d]
V  [jvm.dll+0xf594f]
V  [jvm.dll+0xf7777]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  sun.awt.windows.WComponentPeer.getLocationOnScreen()Ljava/awt/Point;
J  java.awt.Component.getLocationOnScreen_NoTreeLock()Ljava/awt/Point;
J  java.awt.Component.getLocationOnScreen()Ljava/awt/Point;
j  oracle.ewt.lwAWT.LWDataSourceList$Child.getLocationOnScreen()Ljava/awt/Point;+4
J  com.sun.java.accessibility.AccessBridge.getAccessibleBoundsOnScreenFromContext(Ljavax/accessibility/AccessibleContext;)Ljava/awt/Rectangle;
j  com.sun.java.accessibility.AccessBridge.getAccessibleXcoordFromContext(Ljavax/accessibility/AccessibleContext;)I+6
v  ~StubRoutines::call_stub
j  com.sun.java.accessibility.AccessBridge.run()V+0
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x04052400 JavaThread "Image Fetcher 0" daemon [_thread_blocked, id=7976, stack(0x04e60000,0x04eb0000)]
  0x0716ac00 JavaThread "Image Fetcher 0" daemon [_thread_blocked, id=5484, stack(0x07770000,0x077c0000)]
  0x0716a000 JavaThread "Flush Queue" [_thread_blocked, id=4588, stack(0x055d0000,0x05620000)]
  0x04053000 JavaThread "Thread-11" [_thread_in_native, id=6544, stack(0x054f0000,0x05540000)]
  0x04052800 JavaThread "CursorIdler" [_thread_blocked, id=3328, stack(0x054a0000,0x054f0000)]
  0x0404f800 JavaThread "TaskScheduler timer" [_thread_blocked, id=1180, stack(0x05300000,0x05350000)]
  0x04051c00 JavaThread "Busy indicator" daemon [_thread_blocked, id=5072, stack(0x05280000,0x052d0000)]
  0x04051000 JavaThread "HeartBeat" [_thread_blocked, id=3960, stack(0x05230000,0x05280000)]
  0x04050c00 JavaThread "Forms-StreamMessageWriter" [_thread_blocked, id=6008, stack(0x04fc0000,0x05010000)]
  0x04050400 JavaThread "Forms-StreamMessageReader" [_thread_in_native, id=2480, stack(0x04f70000,0x04fc0000)]
  0x0404f400 JavaThread "Keep-Alive-Timer" daemon [_thread_blocked, id=7112, stack(0x059c0000,0x05a10000)]
  0x0404bc00 JavaThread "thread applet-oracle.forms.engine.Main-1" [_thread_blocked, id=4376, stack(0x049b0000,0x04a00000)]
  0x0404e000 JavaThread "AWT-EventQueue-2" [_thread_blocked, id=8020, stack(0x04dc0000,0x04e10000)]
  0x0404dc00 JavaThread "Applet 1 LiveConnect Worker Thread" [_thread_blocked, id=7500, stack(0x04730000,0x04780000)]
  0x0404d400 JavaThread "Browser Side Object Cleanup Thread" [_thread_blocked, id=1888, stack(0x04d70000,0x04dc0000)]
  0x0404d000 JavaThread "Windows Tray Icon Thread" [_thread_in_native, id=4396, stack(0x04b10000,0x04b60000)]
  0x0404c800 JavaThread "CacheCleanUpThread" daemon [_thread_blocked, id=252, stack(0x04ac0000,0x04b10000)]
  0x0404c400 JavaThread "CacheMemoryCleanUpThread" daemon [_thread_blocked, id=7492, stack(0x04a00000,0x04a50000)]
  0x0404b400 JavaThread "Java Plug-In Heartbeat Thread" [_thread_blocked, id=5644, stack(0x04960000,0x049b0000)]
  0x04036c00 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=7224, stack(0x04910000,0x04960000)]
=>0x04036000 JavaThread "Thread-5" [_thread_in_vm, id=5868, stack(0x046e0000,0x04730000)]
  0x04037800 JavaThread "EventQueueMonitor-ComponentEvtDispatch" [_thread_blocked, id=7964, stack(0x04690000,0x046e0000)]
  0x04023800 JavaThread "AWT-Windows" daemon [_thread_in_native, id=7752, stack(0x04640000,0x04690000)]
  0x04023000 JavaThread "AWT-Shutdown" [_thread_blocked, id=1388, stack(0x045f0000,0x04640000)]
  0x04022c00 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=5564, stack(0x045a0000,0x045f0000)]
  0x0086f800 JavaThread "Java Plug-In Pipe Worker Thread (Client-Side)" daemon [_thread_in_native, id=5864, stack(0x043f0000,0x04440000)]
  0x04013400 JavaThread "traceMsgQueueThread" daemon [_thread_blocked, id=3684, stack(0x03f20000,0x03f70000)]
  0x00827400 JavaThread "Timer-0" [_thread_blocked, id=4840, stack(0x03dc0000,0x03e10000)]
  0x00804c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3712, stack(0x03d20000,0x03d70000)]
  0x00800800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=6924, stack(0x03cd0000,0x03d20000)]
  0x007ff000 JavaThread "Attach Listener" daemon [_thread_blocked, id=8092, stack(0x03c80000,0x03cd0000)]
  0x007f4400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6432, stack(0x00970000,0x009c0000)]
  0x007b3c00 JavaThread "Finalizer" daemon [_thread_blocked, id=8136, stack(0x00920000,0x00970000)]
  0x007af400 JavaThread "Reference Handler" daemon [_thread_blocked, id=7184, stack(0x008d0000,0x00920000)]
  0x0022a000 JavaThread "main" [_thread_blocked, id=7496, stack(0x00350000,0x003a0000)]

Other Threads:
  0x007adc00 VMThread [stack: 0x00880000,0x008d0000] [id=7120]
  0x00806000 WatcherThread [stack: 0x03d70000,0x03dc0000] [id=3704]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread:  ([mutex/lock_event])
[0x00227c98] JNIGlobalHandle_lock - owner thread: 0x04036000

Heap
 def new generation   total 1792K, used 1493K [0x236e0000, 0x238d0000, 0x23bc0000)
  eden space 1600K,  92% used [0x236e0000, 0x23850b20, 0x23870000)
  from space 192K,   9% used [0x238a0000, 0x238a4af8, 0x238d0000)
  to   space 192K,   0% used [0x23870000, 0x23870000, 0x238a0000)
 tenured generation   total 22296K, used 18551K [0x23bc0000, 0x25186000, 0x276e0000)
   the space 22296K,  83% used [0x23bc0000, 0x24dddcc8, 0x24ddde00, 0x25186000)
 compacting perm gen  total 12288K, used 8352K [0x276e0000, 0x282e0000, 0x2b6e0000)
   the space 12288K,  67% used [0x276e0000, 0x27f081f8, 0x27f08200, 0x282e0000)
    ro space 8192K,  63% used [0x2b6e0000, 0x2bbf96b0, 0x2bbf9800, 0x2bee0000)
    rw space 12288K,  53% used [0x2bee0000, 0x2c554b80, 0x2c554c00, 0x2cae0000)

Dynamic libraries:
0x00400000 - 0x00424000     C:\Program Files\Java\jre6\bin\java.exe
0x77c60000 - 0x77d9c000     C:\windows\SYSTEM32\ntdll.dll
0x76ee0000 - 0x76fb4000     C:\windows\system32\kernel32.dll
0x760b0000 - 0x760fa000     C:\windows\system32\KERNELBASE.dll
0x77df0000 - 0x77e90000     C:\windows\system32\ADVAPI32.dll
0x76390000 - 0x7643c000     C:\windows\system32\msvcrt.dll
0x768f0000 - 0x76909000     C:\windows\SYSTEM32\sechost.dll
0x76c90000 - 0x76d31000     C:\windows\system32\RPCRT4.dll
0x75d30000 - 0x75d7c000     C:\windows\system32\apphelp.dll
0x61e20000 - 0x61ead000     C:\windows\AppPatch\AcLayers.DLL
0x75d10000 - 0x75d2b000     C:\windows\system32\SspiCli.dll
0x76820000 - 0x768e9000     C:\windows\system32\USER32.dll
0x76630000 - 0x7667e000     C:\windows\system32\GDI32.dll
0x77dc0000 - 0x77dca000     C:\windows\system32\LPK.dll
0x76bb0000 - 0x76c4d000     C:\windows\system32\USP10.dll
0x76fc0000 - 0x77c0a000     C:\windows\system32\SHELL32.dll
0x76100000 - 0x76157000     C:\windows\system32\SHLWAPI.dll
0x76980000 - 0x76adc000     C:\windows\system32\ole32.dll
0x76160000 - 0x761ef000     C:\windows\system32\OLEAUT32.dll
0x75410000 - 0x75427000     C:\windows\system32\USERENV.dll
0x75e00000 - 0x75e0b000     C:\windows\system32\profapi.dll
0x72f20000 - 0x72f71000     C:\windows\system32\WINSPOOL.DRV
0x6fd50000 - 0x6fd62000     C:\windows\system32\MPR.dll
0x77da0000 - 0x77dbf000     C:\windows\system32\IMM32.DLL
0x76ae0000 - 0x76bac000     C:\windows\system32\MSCTF.dll
0x7c340000 - 0x7c396000     C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d800000 - 0x6da8b000     C:\Program Files\Java\jre6\bin\client\jvm.dll
0x743d0000 - 0x74402000     C:\windows\system32\WINMM.dll
0x6d7b0000 - 0x6d7bc000     C:\Program Files\Java\jre6\bin\verify.dll
0x6d330000 - 0x6d34f000     C:\Program Files\Java\jre6\bin\java.dll
0x6d290000 - 0x6d298000     C:\Program Files\Java\jre6\bin\hpi.dll
0x77de0000 - 0x77de5000     C:\windows\system32\PSAPI.DLL
0x6d7f0000 - 0x6d7ff000     C:\Program Files\Java\jre6\bin\zip.dll
0x6d430000 - 0x6d436000     C:\Program Files\Java\jre6\bin\jp2native.dll
0x6d1d0000 - 0x6d1e3000     C:\Program Files\Java\jre6\bin\deploy.dll
0x75f90000 - 0x760ad000     C:\windows\system32\CRYPT32.dll
0x75e70000 - 0x75e7c000     C:\windows\system32\MSASN1.dll
0x76dc0000 - 0x76eda000     C:\windows\system32\WININET.dll
0x77dd0000 - 0x77dd3000     C:\windows\system32\Normaliz.dll
0x76440000 - 0x765f8000     C:\windows\system32\iertutil.dll
0x76710000 - 0x76820000     C:\windows\system32\urlmon.dll
0x6d6b0000 - 0x6d6f3000     C:\Program Files\Java\jre6\bin\regutils.dll
0x753a0000 - 0x753a9000     C:\windows\system32\VERSION.dll
0x6fd80000 - 0x6ffc0000     C:\windows\system32\msi.dll
0x6d610000 - 0x6d623000     C:\Program Files\Java\jre6\bin\net.dll
0x76c50000 - 0x76c85000     C:\windows\system32\WS2_32.dll
0x76970000 - 0x76976000     C:\windows\system32\NSI.dll
0x75870000 - 0x758ac000     C:\windows\system32\mswsock.dll
0x75860000 - 0x75866000     C:\windows\System32\wship6.dll
0x6d630000 - 0x6d639000     C:\Program Files\Java\jre6\bin\nio.dll
0x6d000000 - 0x6d14a000     C:\Program Files\Java\jre6\bin\awt.dll
0x74d00000 - 0x74e9e000     C:\windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll
0x74a40000 - 0x74a53000     C:\windows\system32\DWMAPI.DLL
0x74cc0000 - 0x74d00000     C:\windows\system32\uxtheme.dll
0x75d80000 - 0x75d8c000     C:\windows\system32\CRYPTBASE.dll
0x63420000 - 0x63451000     C:\Program Files\Java\jre6\bin\JavaAccessBridge.dll
0x6d360000 - 0x6d366000     C:\Program Files\Java\jre6\bin\jawt.dll
0x70b90000 - 0x70b9d000     C:\Program Files\Java\jre6\bin\JAWTAccessBridge.dll
0x6d230000 - 0x6d284000     C:\Program Files\Java\jre6\bin\fontmanager.dll
0x759e0000 - 0x759e8000     C:\windows\system32\Secur32.dll
0x75710000 - 0x75754000     C:\windows\system32\dnsapi.DLL
0x73ff0000 - 0x7400c000     C:\windows\system32\iphlpapi.DLL
0x73fd0000 - 0x73fd7000     C:\windows\system32\WINNSI.DLL
0x752f0000 - 0x752f5000     C:\windows\System32\wshtcpip.dll
0x72b70000 - 0x72b94000     C:\Program Files\Common Files\Microsoft Shared\Windows Live\WLIDNSP.DLL
0x72490000 - 0x72496000     C:\windows\system32\rasadhlp.dll
0x73ea0000 - 0x73ed8000     C:\windows\System32\fwpuclnt.dll
0x67d00000 - 0x67d3a000     C:\Program Files\UltraMon\RTSUltraMonHook.dll
0x67d40000 - 0x67d91000     C:\Program Files\UltraMon\UltraMonResButtons.dll
0x74b30000 - 0x74cc0000     C:\windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.17514_none_72d18a4386696c80\gdiplus.dll
0x74680000 - 0x7477b000     C:\windows\system32\WindowsCodecs.dll
0x75920000 - 0x75936000     C:\windows\system32\CRYPTSP.dll
0x75630000 - 0x7566b000     C:\windows\system32\rsaenh.dll
0x74220000 - 0x74230000     C:\windows\system32\NLAapi.dll
0x72bc0000 - 0x72bd0000     C:\windows\system32\napinsp.dll
0x72ba0000 - 0x72bb2000     C:\windows\system32\pnrpnsp.dll
0x72b60000 - 0x72b68000     C:\windows\System32\winrnr.dll

VM Arguments:
jvm_args: -D__jvm_launched=612118666339 -Xbootclasspath/a:C:\\PROGRA~1\\Java\\jre6\\lib\\deploy.jar;C:\\PROGRA~1\\Java\\jre6\\lib\\javaws.jar;C:\\PROGRA~1\\Java\\jre6\\lib\\plugin.jar -Dsun.plugin2.jvm.args=-D__jvm_launched=612118666339 "-Xbootclasspath/a:C:\\\\PROGRA~1\\\\Java\\\\jre6\\\\lib\\\\deploy.jar;C:\\\\PROGRA~1\\\\Java\\\\jre6\\\\lib\\\\javaws.jar;C:\\\\PROGRA~1\\\\Java\\\\jre6\\\\lib\\\\plugin.jar" "-Djava.class.path=C:\\\\PROGRA~1\\\\Java\\\\jre6\\\\classes" --- -- 
java_command: sun.plugin2.main.client.PluginMain write_pipe_name=jpi2_pid7848_pipe3,read_pipe_name=jpi2_pid7848_pipe2
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Toshiba\Bluetooth Toshiba Stack\sys\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Ericsson\Solidus eCare\Applications\Bin;C:\Program Files\Common Files\EricssonShare;C:\Program Files\Common Files\EricssonShare\NextCCShare;C:\Program Files\Ericsson\Solidus eCare\ScriptManager\Bin;C:\Program Files\Ericsson\Solidus eCare\ScriptManager\Bin\ThirdParty;C:\Program Files\Bitvise Tunnelier;C:\Program Files\Internet Explorer;
USERNAME=HomeTest
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 37 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 Build 7601 Service Pack 1

CPU:total 4 (8 cores per cpu, 2 threads per core) family 6 model 37 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, ht

Memory: 4k page, physical 2097151k(951176k free), swap 4194303k(3170808k free)

vm_info: Java HotSpot(TM) Client VM (14.0-b16) for windows-x86 JRE (1.6.0_14-b08), built on May 21 2009 08:03:56 by "java_re" with MS VC++ 7.1

time: Mon Sep 05 09:29:29 2011
elapsed time: 16 seconds

And here is the code that is triggering it:

public static AccessibleTreeItem GetAccessibleContextInfo(Int32 vmID, IntPtr ac, out AccessibleContextInfo acInfo, AccessibleTreeItem parentItem)
{
    unsafe
    {
        // Allocate global memory space for the size of AccessibleContextInfo and store the address in acPtr
        IntPtr acPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleContextInfo()));
        try
        {

            Marshal.StructureToPtr(new AccessibleContextInfo(), acPtr, true);
            if (WABAPI.getAccessibleContextInfo(vmID, ac, acPtr))
            {
                acInfo = (AccessibleContextInfo)Marshal.PtrToStructure(acPtr, typeof(AccessibleContextInfo));
                if (!ReferenceEquals(acInfo, null))
                {
                    IntPtr ati = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleTextItemsInfo()));
                    WABAPI.getAccessibleTextItems(vmID, ac, ati, 0); //THIS IS WHERE WE DO IT
                    AccessibleTextItemsInfo atInfo = (AccessibleTextItemsInfo)Marshal.PtrToStructure(ati, typeof(AccessibleTextItemsInfo));

                    IntPtr ainfo = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleTextInfo()));
                    WABAPI.getAccessibleTextInfo(vmID, ac, ainfo, 0, 0);
                    AccessibleTextInfo atextInfo = (AccessibleTextInfo)Marshal.PtrToStructure(ati, typeof(AccessibleTextInfo));

                    AccessibleTreeItem newItem = BuildAccessibleTree(acInfo, atInfo, parentItem, acPtr, atextInfo);
                    newItem.setAccessibleText(atInfo, atextInfo);
                    if (ati != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(ati);
                    }

                    if (ainfo != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(ainfo);
                    }

                    if (!ReferenceEquals(newItem, null))
                    {
                        for (int i = 0; i < acInfo.childrenCount; i++)
                        {
                            //Used roles = text, page tab, push button
                            if (acInfo.role_en_US != "unknown" && acInfo.states_en_US.Contains("visible")) // Note the optomization here, I found this get me to an acceptable speed
                            {
                                AccessibleContextInfo childAc = new AccessibleContextInfo();
                                IntPtr childContext = WABAPI.getAccessibleChildFromContext(vmID, ac, i);
                                GetAccessibleContextInfo(vmID, childContext, out childAc, newItem);
                                //WABAPI.releaseJavaObject(vmID, childContext);
                            }
                        }
                    }

                    return newItem;
                }
            }
            else
            {
                acInfo = new AccessibleContextInfo();
            }
        }
        finally
        {
            //WABAPI.releaseJavaObject(vmID, ac);
            if (acPtr != IntPtr.Zero)
                Marshal.FreeHGlobal(acPtr);
        }
    }
    return null;
}

When I uncomment the lines that have WABAPI.releaseJavaObject(vmID, jobject) I get the resulting crash. Sometimes. I've put checks around vmID and ac to ensure that they're valid values (i.e. Non 0) and the problem still occurs.

My program works correctly without the releaseJavaObject() lines, but the RAM usage balloons and the whole system will come to a grinding halt. This is to be expected of course, since the JAB documentation advises that all objects need to be released, lest memory leaks occur.

Can someone advise me as to why releaseJavaObject() is crashing?

I should note that the function I'm using above was copy-pasted from the Oracle forums and I haven't investigated how it works very heavily. But that is THE only location unsafe code is used, and all interaction between my app and the JAB happens in that one function.


Solution

  • Because the function was called recursively, it would release the handle to the parent object in the 'finally' block, and then move on to the next child. No parent handle, the function failed (Without any error catching, d'oh) and the JVM crashed on an invalid value for ac.