I am working on a game. At some places, sometimes I receive a segmentation fault and at all other times the code works properly. If I run the game again (after receiving segmentation fault) it recovers back (without any code changes) and runs fine. But after some time again this happens.
I tried debugging it using GDB. I got the following information:
- there is a function call : func(&s.x), where s is a structure and x is its member of type int. The address (&s.x) is 0xb3456721
- In function func the value received in the argument is 0xb.
- The program crashes saying memory at 0xb cannot be accessed. When I print the variable using GDB, I again receive memory cannot be accessed.
Any ideas Why this would happen?