##Perl, 10 / 12 chars
Perl, 10 / 12 chars
A slightly cheatish solution is to shave one char off Joey Adams' bash trick:
kill 11,$$
However, to get a real segfault in Perl, unpack p
is the obvious solution:
unpack p,1x8
Technically, this isn't guaranteed to segfault, since the address 0x31313131 (or 0x3131313131313131 on 64-bit systems) just might point to valid address space by chance. But the odds are against it. Also, if perl is ever ported to platforms where pointers are longer than 64 bits, the x8
will need to be increased.