Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1042719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:33:13+00:00 2026-05-16T15:33:13+00:00

When I exit my C++ program it crashes with errors like: EAccessViolation with mesage

  • 0

When I exit my C++ program it crashes with errors like:

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

and

Abnormal Program Termination

It is probably caused by some destructor because it happens only when the application exits. I use a few external libraries and cannot find the code that causes it. Is there a function that forces immediate program exit (something like kill in Linux) so that memory would have to be freed by the operating system? I could use this function in app exit event.

I know that it would be a terrible solution because it’d just hide the problem.

I’m just asking out of sheer curiosity, so please don’t give me -1 🙂

I tried exit(0) from stdlib but it didn’t help.

EDIT:

Thanks for your numerous replies:)
I use Builder C++ 6 (I know it’s outdated but for some reasons I had to use it). My app uses library to neural networks (FANN). Using the debugger I found that program crashes in:

~neural_net()
{
    destroy();
}

destroy() calls multiple time another function fann_safe_free(ptr), that is:

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

The library works great, problem only appears when it does cleaning. That’s why I asked about so brutal solution. My app is multi-threaded but other threads operate on different data.

I will analyze my code for the n-th time(the bug must be somewhere), thanks for all your tips 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:33:14+00:00Added an answer on May 16, 2026 at 3:33 pm

    You should fix the problem.

    • First step: find at check all functions you register with atexit() (not many I hope)
    • Second step: find all global variables and check their destructors.
    • Third Step: find all static function variables check their destructors.

    But otherwise you can abort.
    Note: abort is for Abnormal program termination.

    abort()
    

    The difference: (note letting an application leave the main function is the equivalent of exit())

    • exit()

      1. Call the functions registered with the atexit(3) function, in the reverse order of their registration. This includes the destruction of all global (static storage duration) variables.
      2. Flush all open output streams.
      3. Close all open streams.
      4. Unlink all files created with the tmpfile(3) function.
    • abort()

      1. Flush all open output streams.
      2. Close all open streams.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like the program to exit if the input number is less than 0,
I have seen some code do this: if(something){ echo 'exit from program'; die; }
I have a GUI program with one Exit button. When clicking this button, it
I am writing an application program using swing. I need to exit from the
How does a thread knows when to exit? SITUATION: -while the main program must
Is there any way to make a program stop and exit the program when
Sometimes I experience random crashes in my Delphi program. My program halts, and the
I get an access violation error in release mode, but not debug mode. The
Which function is used in C++ stdlib to exit from program execution with status
I'm just doing a small program. It's an address book which has four options:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.