JVM crashes when calling C++ DLL

Discussion in 'Java' started by chella mani, Sep 8, 2004.

  1. chella mani

    chella mani Guest

    hi all,
    I am calling functions in existing C\C++ program (DLL) through a
    wrapper C++ program (another DLL) from java.

    ie java <---->Wrapper C++ <-----> Ordinary C++ function

    My problem is JVM crashes(some times) and gives the following error,

    An unexpected exception has been detected in native code outside the
    VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
    at PC=0x80C2F75
    Function=[Unknown.]
    Library=(N/A)

    NOTE: We are unable to locate the function name symbol for the error
    just occurred. Please refer to release documentation for
    possible
    reason and solutions.


    Current Java thread:
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
    at java.lang.Class.getMethod0(Class.java:1893)
    at java.lang.Class.getMethod(Class.java:976)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:726)
    at javax.swing.UIManager.getUI(UIManager.java:784)
    at javax.swing.JToolTip.updateUI(JToolTip.java:82)
    at javax.swing.JToolTip.<init>(JToolTip.java:64)
    at javax.swing.JComponent.createToolTip(JComponent.java:2603)
    at javax.swing.ToolTipManager.showTipWindow(ToolTipManager.java:257)
    at javax.swing.ToolTipManager$insideTimerAction.actionPerformed(ToolTipManager.java:689)
    at javax.swing.Timer.fireActionPerformed(Timer.java:271)
    at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

    Dynamic libraries:
    0x7CC00000 - 0x7CC1D000 C:\WINDOWS\SYSTEM\IMAGEHLP.DLL

    Heap at VM Abort:
    Heap
    def new generation total 4608K, used 234K [0x10010000, 0x10510000,
    0x10ed0000)
    eden space 4096K, 1% used [0x10010000, 0x10021eb0, 0x10410000)
    from space 512K, 31% used [0x10490000, 0x104b8a80, 0x10510000)
    to space 512K, 0% used [0x10410000, 0x10410000, 0x10490000)
    tenured generation total 60544K, used 11740K [0x10ed0000,
    0x149f0000, 0x1c010000)
    the space 60544K, 19% used [0x10ed0000, 0x11a47348, 0x11a47400,
    0x149f0000)
    compacting perm gen total 12032K, used 11914K [0x1c010000,
    0x1cbd0000, 0x20010000)
    the space 12032K, 99% used [0x1c010000, 0x1cbb2ad0, 0x1cbb2c00,
    0x1cbd0000)

    Local Time = Thu Aug 26 18:58:43 2004
    Elapsed Time = 41
    #
    # The exception above was detected in native code outside the VM
    #
    # Java VM: Java HotSpot(TM) Client VM (1.4.2_02-b03 mixed mode)
    #



    Can Any one give me a solution to this problem or way to find out the
    cause of the problem,

    Thanks and Regards,
    Chella.mani
    chella mani, Sep 8, 2004
    #1
    1. Advertising

  2. On 8 Sep 2004 04:00:04 -0700, chella mani wrote:
    > I am calling functions in existing C\C++ program (DLL) through a
    > wrapper C++ program (another DLL) from java.


    [...]

    > My problem is JVM crashes(some times) and gives the following error,
    >
    > An unexpected exception has been detected in native code outside the
    > VM.
    > Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
    > at PC=0x80C2F75


    [...]

    > Can Any one give me a solution to this problem or way to find out the
    > cause of the problem,


    There is a pointer error in one of your native methods. For more
    information, have a look at questions 16.5 and 16.8 in the comp.lang.c
    FAQ:

    http://www.eskimo.com/~scs/C-faq/faq.html

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Sep 8, 2004
    #2
    1. Advertising

  3. chella mani

    Liz Guest

    "Gordon Beaton" <> wrote in message
    news:...
    > On 8 Sep 2004 04:00:04 -0700, chella mani wrote:
    > > I am calling functions in existing C\C++ program (DLL) through a
    > > wrapper C++ program (another DLL) from java.

    >
    > [...]
    >
    > > My problem is JVM crashes(some times) and gives the following error,
    > >
    > > An unexpected exception has been detected in native code outside the
    > > VM.
    > > Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
    > > at PC=0x80C2F75

    >
    > [...]
    >
    > > Can Any one give me a solution to this problem or way to find out the
    > > cause of the problem,

    >
    > There is a pointer error in one of your native methods. For more
    > information, have a look at questions 16.5 and 16.8 in the comp.lang.c
    > FAQ:
    >


    This is a feature of C++ whereas it can run anywhere, including amuck.
    Liz, Sep 8, 2004
    #3
  4. chella mani

    chella mani Guest

    "Liz" <> wrote in message news:<j1M%c.269867$8_6.94848@attbi_s04>...
    > "Gordon Beaton" <> wrote in message
    > news:...
    > > On 8 Sep 2004 04:00:04 -0700, chella mani wrote:
    > > > I am calling functions in existing C\C++ program (DLL) through a
    > > > wrapper C++ program (another DLL) from java.

    > >
    > > [...]
    > >
    > > > My problem is JVM crashes(some times) and gives the following error,
    > > >
    > > > An unexpected exception has been detected in native code outside the
    > > > VM.
    > > > Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
    > > > at PC=0x80C2F75

    > >
    > > [...]
    > >
    > > > Can Any one give me a solution to this problem or way to find out the
    > > > cause of the problem,

    > >
    > > There is a pointer error in one of your native methods. For more
    > > information, have a look at questions 16.5 and 16.8 in the comp.lang.c
    > > FAQ:
    > >

    >
    > This is a feature of C++ whereas it can run anywhere, including amuck.



    The problem is my wrapper program should to allow the user to use his
    existing C\C++ code without any modification. Is it possible to
    Prevent the JVM crash in case of any access violation.
    chella mani, Sep 9, 2004
    #4
  5. On 8 Sep 2004 21:37:41 -0700, chella mani wrote:
    > The problem is my wrapper program should to allow the user to use his
    > existing C\C++ code without any modification. Is it possible to
    > Prevent the JVM crash in case of any access violation.


    First, you can't catch these errors if the operating system policy is
    to kill your process because of them.

    Second, if you have native code that corrupts the process memory, you
    can't really trust *any* results from the program. Even when the
    process doesn't crash, you can't be sure the error hasn't occurred
    (but in some more subtle way). The crash is just a symptom, and hiding
    it from the user is really the *wrong* approach here.

    Would you trust your bank if they used software that attempted to hide
    serious errors? Would you fly in such an aircraft?

    What is the value of telling the user he doesn't have to modify his
    incorrect code?

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Sep 9, 2004
    #5
  6. chella mani

    Chris Uppal Guest

    chella mani wrote:

    > The problem is my wrapper program should to allow the user to use his
    > existing C\C++ code without any modification.


    If you /really/ need that kind of isolation (that the user code can crash
    without killing your application) then this is the wrong way to go about it.
    You need the user's flaky code to be in a completely different process from
    your application, or you /won't/ be isolated from their bugs.

    One approach would be to write a small separate program which loads and runs
    the DLL, and uses TCP/IP (or anything else that's handy) to communicate back
    with the parent application. There are other approaches, it depends on what
    you are doing.

    -- chris
    Chris Uppal, Sep 9, 2004
    #6
  7. chella mani

    chella mani Guest

    Gordon Beaton <> wrote in message news:<>...
    > On 8 Sep 2004 21:37:41 -0700, chella mani wrote:
    > > The problem is my wrapper program should to allow the user to use his
    > > existing C\C++ code without any modification. Is it possible to
    > > Prevent the JVM crash in case of any access violation.

    >
    > First, you can't catch these errors if the operating system policy is
    > to kill your process because of them.
    >
    > Second, if you have native code that corrupts the process memory, you
    > can't really trust *any* results from the program. Even when the
    > process doesn't crash, you can't be sure the error hasn't occurred
    > (but in some more subtle way). The crash is just a symptom, and hiding
    > it from the user is really the *wrong* approach here.
    >
    > Would you trust your bank if they used software that attempted to hide
    > serious errors? Would you fly in such an aircraft?
    >
    > What is the value of telling the user he doesn't have to modify his
    > incorrect code?


    > /gordon


    Yes I agree with you gordon,the user's natvie code runs with out any
    problem when using it as stand alone application,but when ever I call
    the native code through JNI it kills the entire application.In case of
    any access violation I want to show the user that some access
    violation has occured and i want to prevent the entire application
    getting killed.
    chella mani, Sep 10, 2004
    #7
  8. chella mani

    Lans Redmond Guest

    add the -dsa option to the catalina_opts flag

    dsa diables system assertions


    "chella mani" <> wrote in message
    news:...
    > hi all,
    > I am calling functions in existing C\C++ program (DLL) through a
    > wrapper C++ program (another DLL) from java.
    >
    > ie java <---->Wrapper C++ <-----> Ordinary C++ function
    >
    > My problem is JVM crashes(some times) and gives the following error,
    >
    > An unexpected exception has been detected in native code outside the
    > VM.
    > Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
    > at PC=0x80C2F75
    > Function=[Unknown.]
    > Library=(N/A)
    >
    > NOTE: We are unable to locate the function name symbol for the error
    > just occurred. Please refer to release documentation for
    > possible
    > reason and solutions.
    >
    >
    > Current Java thread:
    > at java.lang.Class.getDeclaredMethods0(Native Method)
    > at java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
    > at java.lang.Class.getMethod0(Class.java:1893)
    > at java.lang.Class.getMethod(Class.java:976)
    > at javax.swing.UIDefaults.getUI(UIDefaults.java:726)
    > at javax.swing.UIManager.getUI(UIManager.java:784)
    > at javax.swing.JToolTip.updateUI(JToolTip.java:82)
    > at javax.swing.JToolTip.<init>(JToolTip.java:64)
    > at javax.swing.JComponent.createToolTip(JComponent.java:2603)
    > at javax.swing.ToolTipManager.showTipWindow(ToolTipManager.java:257)
    > at
    > javax.swing.ToolTipManager$insideTimerAction.actionPerformed(ToolTipManager.java:689)
    > at javax.swing.Timer.fireActionPerformed(Timer.java:271)
    > at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
    > at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
    > at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
    > at
    > java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    > at
    > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    > at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    >
    > Dynamic libraries:
    > 0x7CC00000 - 0x7CC1D000 C:\WINDOWS\SYSTEM\IMAGEHLP.DLL
    >
    > Heap at VM Abort:
    > Heap
    > def new generation total 4608K, used 234K [0x10010000, 0x10510000,
    > 0x10ed0000)
    > eden space 4096K, 1% used [0x10010000, 0x10021eb0, 0x10410000)
    > from space 512K, 31% used [0x10490000, 0x104b8a80, 0x10510000)
    > to space 512K, 0% used [0x10410000, 0x10410000, 0x10490000)
    > tenured generation total 60544K, used 11740K [0x10ed0000,
    > 0x149f0000, 0x1c010000)
    > the space 60544K, 19% used [0x10ed0000, 0x11a47348, 0x11a47400,
    > 0x149f0000)
    > compacting perm gen total 12032K, used 11914K [0x1c010000,
    > 0x1cbd0000, 0x20010000)
    > the space 12032K, 99% used [0x1c010000, 0x1cbb2ad0, 0x1cbb2c00,
    > 0x1cbd0000)
    >
    > Local Time = Thu Aug 26 18:58:43 2004
    > Elapsed Time = 41
    > #
    > # The exception above was detected in native code outside the VM
    > #
    > # Java VM: Java HotSpot(TM) Client VM (1.4.2_02-b03 mixed mode)
    > #
    >
    >
    >
    > Can Any one give me a solution to this problem or way to find out the
    > cause of the problem,
    >
    > Thanks and Regards,
    > Chella.mani
    Lans Redmond, Jan 2, 2005
    #8
  9. chella mani

    lredmond Guest

    if not using tomcat then just use the dsa option when you call java
    "Lans Redmond" <> wrote in message
    news:AdVBd.11528$...
    > add the -dsa option to the catalina_opts flag
    >
    > dsa diables system assertions
    >
    >
    > "chella mani" <> wrote in message
    > news:...
    >> hi all,
    >> I am calling functions in existing C\C++ program (DLL) through a
    >> wrapper C++ program (another DLL) from java.
    >>
    >> ie java <---->Wrapper C++ <-----> Ordinary C++ function
    >>
    >> My problem is JVM crashes(some times) and gives the following error,
    >>
    >> An unexpected exception has been detected in native code outside the
    >> VM.
    >> Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
    >> at PC=0x80C2F75
    >> Function=[Unknown.]
    >> Library=(N/A)
    >>
    >> NOTE: We are unable to locate the function name symbol for the error
    >> just occurred. Please refer to release documentation for
    >> possible
    >> reason and solutions.
    >>
    >>
    >> Current Java thread:
    >> at java.lang.Class.getDeclaredMethods0(Native Method)
    >> at java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
    >> at java.lang.Class.getMethod0(Class.java:1893)
    >> at java.lang.Class.getMethod(Class.java:976)
    >> at javax.swing.UIDefaults.getUI(UIDefaults.java:726)
    >> at javax.swing.UIManager.getUI(UIManager.java:784)
    >> at javax.swing.JToolTip.updateUI(JToolTip.java:82)
    >> at javax.swing.JToolTip.<init>(JToolTip.java:64)
    >> at javax.swing.JComponent.createToolTip(JComponent.java:2603)
    >> at javax.swing.ToolTipManager.showTipWindow(ToolTipManager.java:257)
    >> at
    >> javax.swing.ToolTipManager$insideTimerAction.actionPerformed(ToolTipManager.java:689)
    >> at javax.swing.Timer.fireActionPerformed(Timer.java:271)
    >> at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
    >> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
    >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
    >> at
    >> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    >> at
    >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    >> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    >> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    >>
    >> Dynamic libraries:
    >> 0x7CC00000 - 0x7CC1D000 C:\WINDOWS\SYSTEM\IMAGEHLP.DLL
    >>
    >> Heap at VM Abort:
    >> Heap
    >> def new generation total 4608K, used 234K [0x10010000, 0x10510000,
    >> 0x10ed0000)
    >> eden space 4096K, 1% used [0x10010000, 0x10021eb0, 0x10410000)
    >> from space 512K, 31% used [0x10490000, 0x104b8a80, 0x10510000)
    >> to space 512K, 0% used [0x10410000, 0x10410000, 0x10490000)
    >> tenured generation total 60544K, used 11740K [0x10ed0000,
    >> 0x149f0000, 0x1c010000)
    >> the space 60544K, 19% used [0x10ed0000, 0x11a47348, 0x11a47400,
    >> 0x149f0000)
    >> compacting perm gen total 12032K, used 11914K [0x1c010000,
    >> 0x1cbd0000, 0x20010000)
    >> the space 12032K, 99% used [0x1c010000, 0x1cbb2ad0, 0x1cbb2c00,
    >> 0x1cbd0000)
    >>
    >> Local Time = Thu Aug 26 18:58:43 2004
    >> Elapsed Time = 41
    >> #
    >> # The exception above was detected in native code outside the VM
    >> #
    >> # Java VM: Java HotSpot(TM) Client VM (1.4.2_02-b03 mixed mode)
    >> #
    >>
    >>
    >>
    >> Can Any one give me a solution to this problem or way to find out the
    >> cause of the problem,
    >>
    >> Thanks and Regards,
    >> Chella.mani

    >
    >
    lredmond, Jan 3, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhishek Singh

    JVM crashes: Native method, JNI

    Abhishek Singh, Jul 23, 2003, in forum: Java
    Replies:
    2
    Views:
    785
    Nigel Wade
    Jul 23, 2003
  2. Mark
    Replies:
    2
    Views:
    461
  3. Dave Rathnow

    JNI with 1 byte alignment crashes JVM

    Dave Rathnow, Nov 7, 2003, in forum: Java
    Replies:
    2
    Views:
    1,754
    Gordon Beaton
    Nov 7, 2003
  4. Naresh Agarwal

    jvm.dll vs java.dll

    Naresh Agarwal, Jun 14, 2005, in forum: Java
    Replies:
    5
    Views:
    3,790
  5. stacey
    Replies:
    5
    Views:
    3,225
    Nigel Wade
    Dec 3, 2008
Loading...

Share This Page