DEV Community

Discussion on: I'm an Expert in Memory Management & Segfaults, Ask Me Anything!

Collapse
 
pramodkirchki profile image
pramodkirchki

Is there any technique to deliberately cause a segmentation fault and analyze? May be for example, to understand the code-flow in multi-threaded application, probably under a specific application state?

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Dereferencing a null pointer is usually a pretty reliable way of causing a segmentation fault. Of course, in so doing, you're killing the program. You could just as easily use assertions or system calls to deliberately crash in a more controlled manner.