#70 Variant.release() cause JVM crashed

open
nobody
None
5
2014-08-14
2007-12-19
Flybean
No

The dump is the following:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0ee1abda, pid=2648, tid=3580
#
# Java VM: Java HotSpot(TM) Server VM (1.4.2_10-b03 mixed mode)
# Problematic frame:
# C [jacob.dll+0xabda]
#

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

Current thread (0x040de128): JavaThread "ConnectionHandler-20" [_thread_in_native, id=3580]

siginfo: ExceptionCode=0xc0000005, reading address 0x0f028980

Registers:
EAX=0x0f028980, EBX=0x0584f460, ECX=0x00000004, EDX=0x54605420
ESP=0x0584f448, EBP=0x00000000, ESI=0x040de1c4, EDI=0x0f028980
EIP=0x0ee1abda, EFLAGS=0x00010202

Top of Stack: (sp=0x0584f448)
0x0584f448: 040de128 00000000 0584f460 015690c9
0x0584f458: 00000022 0584f460 111fd5d0 00000000
0x0584f468: 545f1718 13622748 040de128 136226e8
0x0584f478: 00000000 00bb6688 111fd5d0 0584f518
0x0584f488: 545f9806 01c58abc 545fcf48 00000000
0x0584f498: 13622748 16cd2490 17ba8140 11713550
0x0584f4a8: 00001000 545f0223 0584f514 0584f518
0x0584f4b8: 00000000 00000000 00000000 00000000

Instructions: (pc=0x0ee1abda)
0x0ee1abca: 24 18 e8 8f ff ff ff 8b f8 83 c4 08 85 ff 74 4d
0x0ee1abda: 66 8b 07 55 f6 c4 40 74 22 8b 6f 08 85 ed 74 1b

Stack: [0x05810000,0x05850000), sp=0x0584f448, free space=253k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [jacob.dll+0xabda]

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J com.jacob.com.Variant.release()V
J com.jacob.com.Variant.safeRelease()V
J com.jacob.com.ROT.clearObjects()V
v ~I2CAdapter
j com.jacob.com.ComThread.Release()V+11
j com.xxx.excel.WorkBook_EXCEL.close()V+59

The segment of WorkBook_EXCEL.java:

public class WorkBook_EXCEL extends XWorkBook
{

public static final int ColorWhite = -4142;
public static final int ColorBlack = 1;
private ActiveXComponent xl;
private Dispatch workbooks;
private Dispatch workbook;
private Dispatch sheet;
private Dispatch cells;
private Dispatch cellBGColor;
private Dispatch cellFont;

public WorkBook_EXCEL()
{
xl = null;
workbooks = null;
workbook = null;
sheet = null;
cells = null;
cellBGColor = null;
cellFont = null;
ComThread.InitSTA();
xl = new ActiveXComponent("Excel.Application");
setProcessVisible(false);
workbooks = xl.getProperty("Workbooks").toDispatch();
}

public void close()
{
Variant f = new Variant(1);
Dispatch.call(workbook, "Close", f);
workbook = null;
Dispatch.call(workbooks, "Close");
workbooks = null;
xl.invoke("Quit", new Variant[0]);
xl = null;
ComThread.Release();
}

Discussion

  • Flybean
    Flybean
    2007-12-19

    Logged In: YES
    user_id=1101814
    Originator: YES

    JACOB version is 1.12

     
  • Flybean
    Flybean
    2007-12-20

    Logged In: YES
    user_id=1101814
    Originator: YES

    Sorry, something missed

    OS : Windows 2003 SP2
    JDK : 1.4.10

     
  • clay_shooter
    clay_shooter
    2007-12-25

    Logged In: YES
    user_id=1189284
    Originator: NO

    Did you try this with version 1.13?

    The code sample is missing code that shows how workbook is assigned a value.

     
  • Flybean
    Flybean
    2007-12-25

    Logged In: YES
    user_id=1101814
    Originator: YES

    The following code segment shows the assignment
    public void getFile(String fileName) {
    workbook = Dispatch.call(workbooks, "Open", fileName).toDispatch();
    setWorkSheet(1);
    xl.setProperty("DisplayAlerts", new Variant(false));
    }

    We do not try Version 1.13, but I asked the programmers to serialize the accessing of the Office COM component, according to the KB on MSDN

    http://support.microsoft.com/kb/257757/

     
  • clay_shooter
    clay_shooter
    2007-12-25

    Logged In: YES
    user_id=1189284
    Originator: NO

    I'll add a reference to the Microsoft technical note in the next build.

    You should try version 1.13. It has some stability improvements. You should also check the version of the JDK you are using. JVM 5 appears to have JNI improvements over JVM 1.4.

    The ControllerTest bundled with the source jar has an example that does almost exactly what your code does without a problem. unittest/com/jacob/test/excel. The test was added in one of the 1.14 milestone builds.

     
  • Flybean
    Flybean
    2007-12-25

    Logged In: YES
    user_id=1101814
    Originator: YES

    It's not easy to upgrade the JDK. Maybe we will upgrade the JACOB to 1.13 with rebuilding.
    Can tell me about the improvement of 1.13? Thanks

     
  • Flybean
    Flybean
    2007-12-25

    Logged In: YES
    user_id=1101814
    Originator: YES

    It's not easy to upgrade the JDK. Maybe we will upgrade the JACOB to 1.13 with rebuilding.
    Can tell me about the improvement of 1.13? Thanks

     
  • clay_shooter
    clay_shooter
    2007-12-25

    Logged In: YES
    user_id=1189284
    Originator: NO

    The 1.13 Release Notes highlights are available on the 1.13 downloads page. Version 1.13 does work with JDK 1.4 but it requires the Visual C 2005 redistributable library that can be downloaded free from the MS web site.

    There is nothing in the code that you've posted that cause the behavior you are seeing.

    Try turning on the -Xcheck:jni command line option. I'm assuming that you meant you were on Sun 1.4.2_10 when you said 1.4.10. The latest Sun 1.4 release is 1.4.2_16. Unless, you are on the IBM JVM in which case I'm not sure what version they are on. "java -version" would tell you.