Friday 7 March 2014

Access violation (segmentation fault)

Access violation is to try to access memory does not exist or does not allow to (like ready-only). Causes can be:
     a) Read/Write access to a memory address which memory bus can't access;
     b) Write access to not-allowed memory section, such as const data section, code section or read-only;
     c) deference to NULL/dangling pointer;

Depend on hardware architecture. x86 generate a general fault protection via software interrupt, which can be captured by the OS. Normally OS will post signal to process and process will crash.

Linux: if able to access to source code, try to implement the segmentation fault handler.
Windows: if able to access to source code, use break point before hitting the segmentation fault
Linux/Windows: Check the dump file. Use gbd/stacktrace or WinGDB


No comments:

Post a Comment