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

  • Home
  • SEARCH
  • 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 3594550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:43:43+00:00 2026-05-18T19:43:43+00:00

Whenever I exit my program it gives me this exception 0xC0000022: A process has

  • 0

Whenever I exit my program it gives me this exception “0xC0000022: A process has requested access to an object, but has not been granted those access rights.”

It breaks right at the end of a function called _lock_file in _file.c.

After trying to narrow down what the cause of the problem is I found out that it does not crash if I remove all fclose() function calls in my program then cleaning and rebuilding my program. Even if the function itself is never called it will still crash. Obviously this solution is not ideal.

When I tried to use fstream instead it produced a similar crash at the start of the program.

It’s also worth mentioning that my program uses SDL.

Edit: Someone requested a minimal example and this is what I cam up with.

main.cpp

#include <stdlib.h>
#include <SDL.h>
/*...*/
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
/*...*/
int main( int argc, char **argv)
{
    if(false)
        fclose(NULL);
    return 0;
}

draw.cpp

/*...*/

If I run this it will crash on exit just like I mentioned above. And yes the draw.cpp is completely commented out, but if I remove it from the project the program will run fine. All other files were removed from the project.

Edit2: In response to karlphillip I decided to double check if it is actually running and it seems that it is actually crashing at the start with this example.

Also it is a Win32 project.

  • 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-18T19:43:44+00:00Added an answer on May 18, 2026 at 7:43 pm

    Are you using the same runtime library (Debug DLL, Debug, Release DLL, Release, etc.) for your main program as was used to build the SDL library? That can often (but not always) cause odd problems, and would be my first port of call when getting this sort of odd behaviour at runtime.

    (If you get an LNK4098 warning when building, this is what it is trying to tell you, and you really need to fix it properly; the “solution” the text of the warning suggests is anything but.)

    Another option is memory corruption. Consider running a debug build, and calling the following on startup:

    _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)|_CRTDBG_CHECK_ALWAYS_DF);
    

    This activates more thorough heap checking. (You might have to go and make a cup of tea when your program runs with this switched on, if it allocates lots of stuff while it’s running.) If then “crashes” in one of the memory allocation functions — it’s actually an assert, you can’t always tell though — then at some point between that call, and the previous call to a memory management function, something has overwritten some memory it should not have. And you can take it from there, to find out what.

    -Edit: “_CRTDBG_REPORT_FLAG_DF”, was probably intended to be “_CRTDBG_REPORT_FLAG”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of my first issues. Whenever I exit out the program, tcpClient.Connect()
When debugging, a trick I do whenever I want to exit the current method
Whenever I run any jython program in Eclipse, I got the following error in
I have been trying to debug my code whenever I had free-time for the
Whenever I run my program with fclose(outputFile); at the very end, I get an
I am receiving a Segmentation Fault error when I run this program. To summarize,
I am trying to extend my company specific BaseClass (Acme::BaseClass) but whenever I: package
I have been using update panels , all i need is whenever a partial
Whenever I design a database, I always wonder if there is a best way
Whenever I try to add a new project to my SourceSafe repository it creates

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.