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.