Advice on diagnosing segfaults?