c++ assert in jni code causes core dump

B

BlueDoze

Helloo,

I'm developing a library with C++, and the interface of the
application will be with java, JNI will be used.
The problem is that whenever assert() occurs, the whole application
core dumps, Is this the normal behavior, or that's a wrong one.
I know that asserts should not be occured in normal cases, but I don't
like the core dump.

Any thoughts.

Bluedoze
 
C

Chris Uppal

BlueDoze said:
The problem is that whenever assert() occurs, the whole application
core dumps, Is this the normal behavior, or that's a wrong one.
I know that asserts should not be occured in normal cases, but I don't
like the core dump.

I don't blame you.

I can't comment on whether there's a mechanism for, say, turning assertion
failure into Java exceptions (though I'm sure it'd be possible to hack up
something).

What I want to say is that you shouldn't be tripping assertions /at all/, not
merely "not in normal case". I don't think assertions should be used for
run-time validation, not after develoment is well advanced, and /certainly/ not
in a deployed application.

If you want run-time validation (which is a perfectly reasonably thing to
want), then /code/ run-time validation. With a proper error return or -- more
likely -- a proper exception thrown.

The only reason to trip an assertion in "real" code is a serious programming
error -- a serious, and unrecoverable, bug. In such cases exiting abruptly
with a core dump (or the equivalent on other systems) is the appropriate thing
to do. I mean what /else/ should a program that has detected an
/unrecoverable/ bug do ?

-- chris
 
G

Gordon Beaton

The problem is that whenever assert() occurs, the whole application
core dumps, Is this the normal behavior, or that's a wrong one. I
know that asserts should not be occured in normal cases, but I don't
like the core dump.

That's normal behaviour for a failed assertion. What do you think
assert() should do insead? And what does this have to do with JNI?

If you don't want a core file, then use ulimit in your command shell
to configure the maximum core file size to 0.

/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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top