5
\$\begingroup\$

This question already has an answer here:

A shortest C program, that can crash the Operating system, either on a Windows or a Linux PC...

Rules:

  • The code is to be developed in C language, but it may use other api, specific to linux or windows systems.
  • The Operating System is said to have been put out of commission, if either it has come to a state[Standstill or otherwise] , where no matter how much time passes, the system is rendered inoperable or (even better), self restarts itself, or something similar to a blue screen of death.
  • To be most effective, the program will be run as a normal user and not as superuser or an administrator.
  • For every valid program that is able to crash the PC, countermeasures can be suggested by others in the comments, successful measures that can nullify the effect of the program gets the answer invalidated. For Example - If an answer suggests use of fork Bombs, i would suggest measures like this in the comments.
  • Since Linux OS is considered more stable, a program that crashes linux is always a better one, even if it takes extra code than it takes to crash windows, but still the smallest program to crash the OS wins, independent of the platform.
  • The community is free to edit the question to add more sensible rules, provided the new rules maintain compatibility with existing answers.

Note: This above question is asked with the purpose of demonstrating the raw power of C[or the lack of it] as a low level/mid level language. Also hopefully, to become more aware of OS security, and possible measures that can be taken.

EDIT:

A similar question lies here Code Golf of Death...

But here are the reasons my question differs from the above mentioned one...

  1. I am looking for the answers to only be in C language.
  2. Though the above question has one answer in C, the code works only for a rare version of pentium 5. So in short there is no C language based answer in the above question to achieve the end purpose.
  3. In the other question Kernel-mode drivers are allowed, but my question concentrates mainly on user space processes.
  4. Some of the answers in the above question allow the programs to run in supervisor/administrator mode, but such privileged execution of the program is not allowed in the rules stated by my question.
  5. In the similar question the answer with highest upvotes win, in my question answer which crashes the OS , using the shortest code, and does so without any suggestion of countermeasure to be taken against the method employed by the answer.
  6. In short, apart from the same intention of crashing the OS , the two questions differ in every other aspect.
\$\endgroup\$

marked as duplicate by Peter Taylor, FUZxxl, Howard, grc, ardnew May 8 '13 at 23:27

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.

  • 1
    \$\begingroup\$ @PeterTaylor Tried searching for a similar question before posting this one , but could not find any(why would i think of searching "Code Golf of Death" :) ). Thanks for giving a link to a similiar question. But the question is not an exact duplicate , since i want my code to be short , and to be in C, not bash or any other language. Also i've added the option where countermeasures are given in comments.Though the intention of the questions are same , the approach and purpose of doing so is different. \$\endgroup\$ – Barath Bushan May 8 '13 at 18:35
  • \$\begingroup\$ I found it by searching for "crash", but I did have the advantage of a vague memory that there had been a similar question before. I agree that it's not an exact duplicate, but it's close enough that any answer to this question would be a valid answer to the other one, and the existing C answers to the other question would be valid answers to this one. I regard the wording "exact" in the close reason as unhelpful; if the essence of the question is the same, there's no benefit to splitting or duplicating the answers. Feel free to start a topic in meta about what "duplicate" means. \$\endgroup\$ – Peter Taylor May 8 '13 at 18:45
  • \$\begingroup\$ @PeterTaylor, if you say its a duplicate, then it sure is, since you have been using this site for 2 years....But still am not satisfied enough with the C solutions in the other question ,simply because there is none, and the only solution (which is a really good one) , relies on a very rare version of pentium 5(and outdated too)....But still please free to close the question if you still feel it is appropriate to do so.... \$\endgroup\$ – Barath Bushan May 8 '13 at 18:59
  • \$\begingroup\$ I am fine with the question being closed as duplicate, but why the downvotes...I have adhered to the faq guidelines as far as possible, is there something i missed ?? \$\endgroup\$ – Barath Bushan May 9 '13 at 1:11
  • 1
    \$\begingroup\$ Shame it's closed. You said the community can edit the rules as long as they accept existing answers. I was gonna add a rule "boothby's solutions are allowed to presume the use of a sledgehammer" and win with a zero character program! \$\endgroup\$ – boothby May 9 '13 at 3:20
6
\$\begingroup\$

29 chars

Linux

int main(){system("init 6");}

I know, very lame. But hey, it reboots the system. Wasn't that the task?

Windows 38 chars

int main(){system("shutdown.exe /r");}

Works as normal user.

\$\endgroup\$
  • 1
    \$\begingroup\$ +1 for exploiting the vulnerability in the rules of the question itself, but clearly in the context of the question, self restarts itself means typically the system self restarting after a crash....so this answer is a no go... \$\endgroup\$ – Barath Bushan May 8 '13 at 19:06
  • \$\begingroup\$ Depends if you see init as part of the system or not (I just tell init to reboot). \$\endgroup\$ – Johannes Kuhn May 8 '13 at 19:11
  • \$\begingroup\$ True...Init is part of the system ,...But the reboot is a graceful one, not a crash... \$\endgroup\$ – Barath Bushan May 8 '13 at 19:19
  • \$\begingroup\$ Why not halt? You shave 2 chars and it doesn't even come back... \$\endgroup\$ – boothby May 9 '13 at 3:16
  • \$\begingroup\$ according to the task, restart is better. \$\endgroup\$ – Johannes Kuhn May 9 '13 at 9:27

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