[Question]
  [
**Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers.
 
 
---
 This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic).
Closed 7 years ago.
[Improve this question](/posts/16702/edit) 
There are a range of questions revolving around this concept, but these all seem to just involve causing a crash, resulting in many answers which are very obviously designed to cause a crash. So the challenge I set you is to write some plausible code (although what the codes supposed "intention" is I leave up to you), that crashes either the entire target OS, or just itself, in a way which is not immediately obvious. (I realize that what counts as "immediately obvious" is subjective, but hopefully the challenge is still reasonably clear).
The winner is the answer with the most votes after 5 days.
  
[Answer]
# C, linux. Crashes system if run as root
```
/* Fork child process, wait 5 seconds and kill it */
pid_t pid = fork();
if(pid =! 0) {
    /* Parent */
    sleep(5);
    kill(pid, 11);
}
else {
    /* Child process. Would contain some code */
}
```
By changing `!=` to `=!`, an innocent comparison is turned into an assignment. And given that pid 1 is `init`, and killing `init` causes a kernel panic, this is not code you would want to run as root :)
[Answer]
## C#
Let's just initialize a list of bytes with every byte value from 0 to 255.
```
List<byte> bytes = new List<byte>();
for (byte i = 0; i <= 255; i++)
{
    bytes.Add(i);
}
```
Out of memory? I distinctly recall having more than 256 bytes installed...
**Spoiler:**
> 
>  A byte will *always* be less than or equal to 255. Addition wraps around from 255 to 0.
> 
> 
> 
[Answer]
# **C**
```
#include <stdio.h>
int main(void) {
   fputs(stdout, "Hello, world!\n");
   return 0;
}
```
(Compiler warnings will give it away.)
[Answer]
# JavaScript
```
var arr = [3,6,1,54,2,-4,8,10,3,7]
function qs(a) {
    if (a.length < 2) return a
    var part = a.shift()
    var higher = [], lower = []
    for (var i = 0; i < a.length; i ++) {
        var x = a[i] // *** THIS LINE ***
        (x < part ? lower : higher).push(x)
 }
    return qs(lower).concat([part]).concat(qs(higher))
}
alert(qs(arr))
```
Working quicksort, except for the fact that lack of semicolon on the line I marked with a comment causes it to parse wrong and crash.
Adding a semicolon at the end of that line fixes it.
[Answer]
# C++
Inputs names and store them in a vector. Prints names upon entry of flag value. Asks if user thought of more names; if so, inputs names.
```
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void print(const vector<string>& v) {
  for (int i = 0; i <= names.size(); i++)
    cout << v[i] << endl;
}
void input(vector<string>& v) {
  string tmp;
  cout << "Enter a list of names seperated by returns: ";
  do {
    getline(cin, tmp);
    if (tmp != "-1")
      v.push_back(tmp);
  } while (tmp != "-1");
  print(v);
}
int main() {
  vector<string> names;
  string tmp;
  do {
    input(names);
    cout << "Do you have any more names to input (y or n)? ";
    cin >> tmp;
  } while (tmp == "y");
  return 0;
}
```
For non-C++, Java, C users, the error is in `print()`s `for` statement. It should be `for (int i = 0; i < names.size(); i++)`. This is an easy error to make and overlook (until you get the compiler message) because it is only 1 character and because the >= operator is sometimes required in `for` loops.
[Answer]
## [GTB](http://timtechsoftware.com/gtb "GTB")
```
:""→_[_+"+"→_]
```
Crashes the calculator because `[_+` should be `["_"+`, but since it isn't, the calculator runs out of memory, potentially clearing the RAM in the wrong way.
]