Comments on Bytes to Segfault
Parent
Bytes to Segfault
Challenge
Cause the currently running program to receive the SIGSEGV signal (on Linux or other *nix systems) as fast as possible. What it does with the signal doesn't matter as long as it receives it.
This is code golf, smallest answer in each language wins. Some languages will have a tougher time than others. Keep in mind that if you depend on uninitalized data, it needs to always result in a segfault; a 0.000001% chance to not work invalidates your solution.
Example program
#include <stddef.h>
#include <stdio.h>
int main() {
int* ohno = NULL;
printf("%d", *ohno);
}
C, 5 bytes ```c main; ``` …
4y ago
[Python 2], 13 bytes …
4y ago
[Bash], 11 kill -11 …
4y ago
[JavaScript (Node.js)], 35 32 …
4y ago
Rust 1.0.0, 58 53 52 37 bytes …
4y ago
C, 16 bytes ```c m(){(int)m= …
4y ago
C (compliant), 19 bytes (`g …
4y ago
Ruby, 14 bytes ```ruby `ki …
3y ago
[Rust], 47 bytes fn …
3y ago
Swift 5.4, 17 bytes ``` fu …
3y ago
Post
C, 5 bytes
main;
This exploits the fact that uninitialised globals live in the .bss
section, and that section is not executable. So any attempt to execute code there, regardless of content, will cause a segfault.
0 comment threads