How to complete a program in C ++

When I exit my C ++ program, it crashes with errors, for example:

EAccessViolation with mesage 'Access violation at address 0...

and

Abnormal Program Termination

This is probably caused by some kind of destructor, because it only happens when the application exits. I use several external libraries and cannot find the code that calls it. Is there a function that forces the program to exit immediately (something like kill on Linux), so that memory must be freed by the operating system? I could use this function in the application exit event.

I know this will be a terrible decision, because it will just hide the problem.

I just ask out of curiosity, so please don't give me -1 :)

I tried exit(0)from stdlib but that didn't help.

EDIT:

:) Builder ++ 6 ( , , ). (FANN). , , :

~neural_net()
{
    destroy();
}

destroy() fann_safe_free (ptr), :

#define fann_safe_free(x) {if(x) { free(x); x = NULL; }}

, . . , .

n- ( -), :)

+3
8

.

  • : , atexit() ( , )
  • : .
  • : , .

.
: Abnormal.

abort()

: (, , exit())

  • ()

    • , atexit (3), . ( ).
    • .
    • .
    • , tmpfile (3).
  • ()

    • .
    • .
+7

. (), , .

, ?

, , . , /, .

Edit:

, :

, .

, , , NULL. ~ neural_net , "this", , NULL. , , , , , NULL delete.

NULL, dest, , , .

+4

abort(); ( <stdlib.h> <process.h>)

Visual++, , , : ". Runtime , , "

+2

Linux/UNIX _exit:

#include <unistd.h>
void _exit(int status);

_exit() exit(), , atexit() on_exit(). , - , tmpfile(3), . , _exit() , , . , tcflush() _exit(). , - - - _exit(), .

+1

? / , , , , , . - - , , . , .

:)

+1

( , ) ()

0

, , - NULL. , .

0

If you are using Linux, valgrind should solve your problem. but if these are windows, try one of them: MemoryValidator, BoundsChecker, or other tools like these.

Just close the application, this is not the best way to handle errors ...

0
source

Source: https://habr.com/ru/post/1762936/


All Articles