1
\$\begingroup\$

This question already has an answer here:

Write the shortest program which, when run with no arguments, stdin, or user input, triggers a core dump.

Your code must behave this way when run on some common out-of-the-box Linux distribution. Other than installing support for your target language, you may not reconfigure the system to make it more fragile than it is as provided.

25-byte C example: int main(){*((int*)0)=0;} on my Ubuntu outputs

Segmentation fault (core dumped)
\$\endgroup\$

marked as duplicate by betseg, TuxCrafting, mbomb007, Rɪᴋᴇʀ, DJMcMayhem Dec 2 '16 at 17:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 6
    \$\begingroup\$ related \$\endgroup\$ – Arnauld Dec 2 '16 at 11:53
  • \$\begingroup\$ I'm posting here since I'm not sure if this is right, but is perl -ue '' a valid solution? (question intended for people knowing perl) \$\endgroup\$ – Dada Dec 2 '16 at 12:40
  • \$\begingroup\$ @Dada, when running that I get Aborted (core dumped) instead of Segmentation fault (core dumped). \$\endgroup\$ – redstarcoder Dec 2 '16 at 13:42
  • 1
    \$\begingroup\$ @redstarcoder It doesn't have to be a segfault, so that would work. \$\endgroup\$ – mbomb007 Dec 2 '16 at 14:37
  • \$\begingroup\$ We already have questions for the fastest way to create a SIGSEGV and the fastest way to create a SIGILL. Dumping core on Linux without a signal is likely to be very verbose compared to crashing in a way that creates a core file, so this question is basically "shortest way to cause a SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGBUS, SIGSYS, SIGTRAP, SIGXCPU, or SIGXFSZ". I think we'd be better off with those as separate questions, rather than having a combined question for any (especially as some of the existing SIGSEGV/SIGILL are very short). \$\endgroup\$ – user62131 Dec 2 '16 at 16:19
7
\$\begingroup\$

C, 5 bytes

main;

Try it online!

Slightly longer, 7 bytes

main=0;
\$\endgroup\$
  • \$\begingroup\$ Why did I get downvoted? This is my first post ever. \$\endgroup\$ – Henrik Hasell Dec 2 '16 at 15:57
  • 1
    \$\begingroup\$ I can't guarantee this is what happened, but it's possible that your post was flagged as low-quality because it was short, and then the system itself casted a downvote because you edited. We really dislike this behavior, but it's something the system does that we can't change. \$\endgroup\$ – DJMcMayhem Dec 2 '16 at 16:13
  • \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! The downvote was cast automatically by the Community user when you edited your answer. I consider this a bug. \$\endgroup\$ – Dennis Dec 2 '16 at 16:15
  • 1
    \$\begingroup\$ The "maximum golfed" answer counts as 9 bytes; it's 2 in the file itself, but has 7 bytes of penalties (Dm=main) because it requires an unusual compiler configuration (you'd write it as "2+7 = 9 bytes"). In general, trying to hide code in the compiler configuration or the program's filename is a cheap tactic, and the penalties are intended to prevent it improving your score except in cases where it's interesting. \$\endgroup\$ – user62131 Dec 2 '16 at 16:22
  • \$\begingroup\$ Well said! I will remove it. \$\endgroup\$ – Henrik Hasell Dec 5 '16 at 11:04
6
\$\begingroup\$

Jelly, 2 bytes

×ß

TryItOnline!

A dyadic atom (here ×, but there are swathes of others) followed by the quick ß which instructs to call the same link (the whole line of code) with the same arity - calling it once more with any arity would also work, so, since it is the only line of code, ß could be replaced by any of ¢ÇçÑñ (last link as a nilad, last link as a monad, last link as a dyad, next link as a monad, or next link as a dyad).

\$\endgroup\$
3
\$\begingroup\$

NASM, 3 bytes

ret

I guess it tries to jump to whatever is on the default stack and immediately segfaults :).

Built with: nasm -f elf64 golf.asm && ld golf.o -o golf

\$\endgroup\$
2
\$\begingroup\$

BASH, 10 bytes

kill -6 $$

kill -6 precisely does this

\$\endgroup\$
0
\$\begingroup\$

C, 14 bytes

main(c){c/=0;}

It's that simple 8-)

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.