Trapping JNI errors

A

Aaron Fude

Hi,

Is it possible to trap these to prevent the program from crashing?

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at
PC=0x899A836
Function=Java_mush_MyClass_myFunction+0x19572


Thanks!
 
G

Gordon Beaton

Is it possible to trap these to prevent the program from crashing?

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at
PC=0x899A836
Function=Java_mush_MyClass_myFunction+0x19572

No, and you really don't want to either.

There is a serious error in your program. You have a corrupt pointer
somewhere. Continuing as though nothing were wrong will likely only
make things worse.

It's like saying that there is a funny banging noise coming from your
brakes, and rather than force the driver to stop, you're looking for a
way to stop the noise from bothering him.

You'll find some clues here:
http://www.eskimo.com/~scs/C-faq/q16.8.html

If it isn't too long, post the native method where the error occurs.

/gordon
 
A

Aaron Fude

Gordon Beaton said:
No, and you really don't want to either.

There is a serious error in your program. You have a corrupt pointer
somewhere. Continuing as though nothing were wrong will likely only
make things worse.

Yes, there's a serious problem - but it's not my program! It is somebody
elses program and I use it. It has a funny bug which makes it crash every
100000th time it is used (there's a random component). If I can just say "ok
you made an error, I will swallow it and let you try again" I will be able
to keep my java simulations going. As it is, my java crashes along with the
jni method.
 
A

Andrew Thompson

....
Yes, there's a serious problem - but it's not my program! It is somebody
elses program and I use it.

I think you might be able to extend
what Gordon said to add.

...then you will need to approach the
author of the 'seriously problematic'
program for a fixed version.

[ My apologies, Gordon, if I got that wrong. ]

(& could I ask you to trim quotes to the minimum
neded to provide context Aaron? It would help
drop the bandwidth necessary to read the group
if we all did it.)
 
G

Gordon Beaton

Yes, there's a serious problem - but it's not my program! It is
somebody elses program and I use it. It has a funny bug which makes
it crash every 100000th time it is used (there's a random
component). If I can just say "ok you made an error, I will swallow
it and let you try again" I will be able to keep my java simulations
going. As it is, my java crashes along with the jni method.

Ok lets say you could ignore the error and continue. But you've got a
stray pointer, and you don't know how it got there. What is extremely
likely is that other variables and possibly the program stack have
also been corrupted. That stray pointer could just as well have
pointed somewhere into a valid data segment in the process, and made
subtle changes there *without* causing a segmentation fault (yet).

Can you trust the program to behave properly after that?

Can you trust *any* return values from that method?

Would you fly in that aircraft, or transfer money from your account in
that bank?

I would put pressure on the author of the native method, or spend my
money elsewhere.

/gordon
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top