c++ assert in jni code causes core dump

Discussion in 'Java' started by BlueDoze, May 4, 2004.

  1. BlueDoze

    BlueDoze Guest

    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
     
    BlueDoze, May 4, 2004
    #1
    1. Advertising

  2. BlueDoze

    Chris Uppal Guest

    BlueDoze wrote:

    > 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
     
    Chris Uppal, May 4, 2004
    #2
    1. Advertising

  3. On 4 May 2004 02:13:48 -0700, BlueDoze wrote:
    > 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

    --
    [ 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, May 4, 2004
    #3
    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. Replies:
    2
    Views:
    1,849
  2. halfdog
    Replies:
    12
    Views:
    12,594
  3. Alex Vinokur

    assert(x) and '#define ASSERT(x) assert(x)'

    Alex Vinokur, Nov 25, 2004, in forum: C Programming
    Replies:
    5
    Views:
    958
    Keith Thompson
    Nov 25, 2004
  4. Jake
    Replies:
    1
    Views:
    331
    mlimber
    Nov 11, 2005
  5. loudking

    free causes core-dump

    loudking, Jan 9, 2008, in forum: C Programming
    Replies:
    4
    Views:
    940
    Keith Thompson
    Jan 11, 2008
Loading...

Share This Page