JVM crashes when calling C++ DLL  
Author Message
chellamani





PostPosted: 2004-9-8 19:00:00 Top

java-programmer, JVM crashes when calling C++ DLL 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
 
Gordon Beaton





PostPosted: 2004-9-8 21:34:00 Top

java-programmer >> JVM crashes when calling C++ DLL 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
 
Liz





PostPosted: 2004-9-9 6:51:00 Top

java-programmer >> JVM crashes when calling C++ DLL
"Gordon Beaton" <email***@***.com> wrote in message
news:email***@***.com...
> 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.


 
 
chellamani





PostPosted: 2004-9-9 12:38:00 Top

java-programmer >> JVM crashes when calling C++ DLL "Liz" <email***@***.com> wrote in message news:<j1M%c.269867$8_6.94848@attbi_s04>...
> "Gordon Beaton" <email***@***.com> wrote in message
> news:email***@***.com...
> > 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.
 
 
Gordon Beaton





PostPosted: 2004-9-9 17:01:00 Top

java-programmer >> JVM crashes when calling C++ DLL 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
 
 
Chris Uppal





PostPosted: 2004-9-9 18:42:00 Top

java-programmer >> JVM crashes when calling C++ DLL 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




 
 
chellamani





PostPosted: 2004-9-10 12:42:00 Top

java-programmer >> JVM crashes when calling C++ DLL Gordon Beaton <email***@***.com> wrote in message news:<email***@***.com>...
> 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.
 
 
Lans Redmond





PostPosted: 2005-1-3 0:23:00 Top

java-programmer >> JVM crashes when calling C++ DLL add the -dsa option to the catalina_opts flag

dsa diables system assertions


"chella mani" <email***@***.com> wrote in message
news:email***@***.com...
> 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





PostPosted: 2005-1-3 11:56:00 Top

java-programmer >> JVM crashes when calling C++ DLL if not using tomcat then just use the dsa option when you call java
"Lans Redmond" <email***@***.com> wrote in message
news:AdVBd.11528$email***@***.com...
> add the -dsa option to the catalina_opts flag
>
> dsa diables system assertions
>
>
> "chella mani" <email***@***.com> wrote in message
> news:email***@***.com...
>> 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
>
>