Skip to content

(Linux) Generate dummy segmentation fault

Create a new C file.

#include <stdio.h>

int main()
    puts((void *)((unsigned long long)-1));
    return 0;


Compile and run.

[root@slave log]# gcc -o seg seg.c
[root@slave log]# ./seg
Segmentation fault
[root@slave log]# tail /var/log/messages
Aug 26 23:39:18 slave kernel: seg[7788]: segfault at fffffffffffffff0 ip 00007fee2413c231 
sp 00007ffdb268c488 error 4 in[7fee240bb000+18a000]
[root@slave log]#

It is very useful if you are working on custom monitoring to track segfault daemons/services/applications on your server.

Published inLinuxTutorials

Be First to Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.