Google interview question

How would you write a program to detect memory segmentation faults?