Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Team,

I have converted unix code to windows in visual studio 2022.

Got compiled successfully. But when i execute the program getting the below error on run time.
Exception thrown at 0x00007FFA3ED10369 (ucrtbased.dll) in NDCSIM.exe: 0xC0000005: Access violation writing location 



on the variables/structure which i have declared in header files.

if i declare those variable as global in same file, it is working fine. I cant able to replace all variables as it is a big application.

Kindly help. TIA.

What I have tried:

tried by declaring all variables in global in one file it is working. But showing same error in another files.
Posted
Updated 1-Feb-23 2:09am
Comments
CPallini 1-Feb-23 3:58am    
Our wizard is in temporary vacancy, please post some code in order to get help from us common people.
Rick York 1-Feb-23 10:58am    
This is one of many reasons that using global variables is not recommended.

Quote:
tried by declaring all variables in global in one file
Until you know the actual cause of the problem you should not change anything; you could just make things worse, or hide the actual bug.

The exception code means you are trying to write to an address that is not within your allocated address space. The only way to find out why is to run the code in the debugger. When the exception occurs you should be able to inspect the stack trace to find out which part of your code is the cause.
 
Share this answer
 
Well, the only thing anyone can tell you is that you have a pointer that's pointing to memory your app does not own, like address 0x00000000. You cannot write to that address because it's owned by the O/S.

You're going to have to debug your code to find out why that pointer is not valid. Nobody can do that for you, nor can they tell you how to fix it because you haven't shown the offending code.

Chances are really high that your code is just assuming some call returned an object or some value or block of memory when it really failed and you're just ignoring the return value signalling that. Then you're trying to use the returned object without checking to see if the function that made that object was successful.

Or you're using a pointer that you didn't initialize to a proper value first.
 
Share this answer
 
I had a similar issue where code that was running correctly before suddenly gave a similar error. It turned out to be because I had plugged in a second monitor. Unplugging it fixed the issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900