[Question]
  [
**Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers.
 
 
---
**Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/6887/edit).
Closed 8 years ago.
[Improve this question](/posts/6887/edit) 
Write programs that produce crazy, obscure, ridiculous, or just plain nutty runtime errors. Obfuscation and golfitude (shortness) not required.
* solutions that look like they should work fine are better.
* solutions that look like they should break one way but break another are better.
* solutions that are nondeterministic are better as long as they are reproducible sometimes.
* solutions with long distance between error cause and manifestation are better.
* bonus points for producing errors that should be impossible.
* bonus points for errors that crash the runtime (like making python segment fault) or operating system.
The unit of score shall be upvotes.
**Addendum 1**
Compiler misbehaviors are fine too.
  
[Answer]
The obligatory PHP one (which *still* hasn't been fixed as of 5.4):
```
<?::
```
Outputs:
```
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM on line 1
```
Whaa?
[Answer]
Gcc compile error:
```
int main()
{
        long long long a;
}
```
error: long long long is too long for GCC
[Answer]
## Windows Command Prompt
```
If you're happy and you know it clap your hands!
```
Output:
> 
> happy was unexpected at this time.
> 
> 
> 
[Answer]
# PHP
```
$ cat error.php 
<?php
function echo_string(string $string) {
    echo $string;
}
echo_string("Hello, world!");
$ php error.php 
PHP Catchable fatal error:  Argument 1 passed to echo_string() must be an instance of string, string given, called in error.php on line 5 and defined in error.php on line 2
```
You cannot pass a string to a function, you have to pass a string instead!
**Update:** This code is NOT an error in PHP 7. Hover on/click/touch a spoiler to check why (contains spoilers about how the code works).
> 
>  A new feature known as [scalar type declarations](https://secure.php.net/manual/en/migration70.new-features.php#migration70.new-features.scalar-type-declarations) was added in PHP 7. This feature allows using scalar types in function declarations.
> 
> 
> 
[Answer]
# bash
```
$ echo "Hello, world!"
bash: !": event not found
```
And you would think that bash would accept a simple "Hello, world!" program.
[Answer]
# Python 2.7
```
# Look I'm actually coding: see my happy face?
print ':)'
```
Generates the rather unhelpful:
```
SyntaxError: encoding problem: with BOM
```
How can a simple comment generate an error?
[Answer]
## Mathematica
When using Mathematica to create graphical output, one sometimes triggers error messages formatted according to specifications being used in the program itself. Here is a trivial example.
```
Rotate[f/0, .6]
```
![enter image description here](https://i.stack.imgur.com/ATksK.png)
[Answer]
## [TI-89 Graphing Calculator](https://en.wikipedia.org/wiki/TI-89_series)
I discovered this when learning about implicit differentiation in high school calculus. If you input:
```
d(xy+x=0,x)
```
You get the following:
```
1 = 0
```
With this caveat, printed in tiny letters at the bottom of the screen:
```
Warning: May produce false equation
```
This happens because `xy` is not interpreted as `x * y`, but rather as its own symbol, `xy`.
Oddly, if you do `d(xy=0,x)`, you get `0 = 0` with the same warning.
[Answer]
You can make the Haskell compiler's brain explode:
```
C:\Windows\system32>ghci
...
Prelude> :set -XExistentialQuantification
Prelude> data Foo = forall a. Foo a
Prelude> let foo f = 1 where Foo a = f
<interactive>:4:21:
    My brain just exploded
    I can't handle pattern bindings for existential or GADT data constructors.
    Instead, use a case-expression, or do-notation, to unpack the constructor.
    In the pattern: Foo a
    In a pattern binding: Foo a = f
    In an equation for `foo':
        foo f
          = 1
          where
              Foo a = f
Prelude>
```
[Answer]
## Ruby
Rules abuse.
```
class StandardError
  def to_s
    words = File.open('/usr/share/dict/words'){|f|f.readlines.map &:chop}.sample(100)
    words.last.capitalize!
    super.gsub(/\w+/){words.pop}
  end
  to_s(3)
end
```
If run on OSX, produces, e.g.
```
$ ruby weird_runtime_error.rb 
weird_runtime_error.rb:9:in `to_s': Sculpturation contingence explicate tappet(phonendoscope ethopoeia nannandrous) (ArgumentError)
    from weird_runtime_error.rb:9:in `<class:StandardError>'
    from weird_runtime_error.rb:1:in `<main>'
```
[Answer]
**DOS Prompt**
```
c:\>make love
```
gives you
```
Fatal Error: 'love' does not exist. Don't know how to make it.
```
Stumbled upon this while I was trying to insult my computer for being uncooperative. Made me kinda sad for a while until I found out, that this only happens if love does not exist. If it exists he will gladly make it.
[Answer]
# Bash (Quine error)
This error is a Quine in Bash!
```
$ bash: bash:: command not found...
bash: bash:: command not found...
```
Of course you must have the relevant `locale` (english here).
[Answer]
# CSH
A really classical `csh` joke:
```
% make fire?
make: No match.
```
[Answer]
# Bash - accurate recreation of a [rare historical error message](https://en.wikipedia.org/wiki/Lp0_on_fire)
```
echo -ne $(tail -n +257 /usr/src/linux*/drivers/char/lp.c | head -1 | cut -d '"' -f 2 | sed 's/%d/0/')
```
Output:
```
lp0 on fire
```
Requires the linux kernel source to be unpacked in the usual place.
Fun fact: i once received this message in earnest, when running an old ribbon printer.
[Answer]
## Ruby
Feel like it's weird that this can happen in a high-level language.
```
$*<<$*<<$**$/
```
produces
```
ArgumentError: recursive array join
```
[Answer]
## C(++)
If compile-time errors count here's one (assuming a file named "crash.c").
```
#include "crash.c"
int main(){ return 0; }
```
It fills the screen with this upon compilation (have Ctrl-C ready)
```
                 from crash.c:1,
                 from crash.c:1:
crash.c:3:1: error: redefinition of ‘main’
crash.c:3:1: note: previous definition of ‘main’ was here
In file included from crash.c:1:0,
                 from crash.c:1,
                 from crash.c:1,
```
Another snippet which compiles perfectly well (no warnings under `-Wall` and illustrates the beautiful type safety of C </s>
```
#include <stdio.h>
int i;
int main(){
  sprintf(NULL, "%s", (char *) (void *) (1/i));
  return 0;
}
```
Running it gives:
```
Floating point exception (core dumped)
```
[Answer]
This is very old, but for those who remember BCPL, 
```
GET "LIBHDR"
LET START() = VALOF 
$8
        RESULTIS 0
$)
```
would complain
```
$8
 ^
"( ) or 8 expected"
```
[Answer]
# R
This is technically not an error but a warning but nevertheless it's ridiculous, and occurs for completely esoteric reasons.
[[EDIT]] It seems that the cause of some parts of the funny warnings resides in RStudio rather than R per se, so it's less interesting than I first thought. The first example i.e `plot(1:2, NotAGraphicalParameter = "ignore.me")` is, however, still reproducible in "naked" R and is funny enough on its own right.[[/EDIT]]
```
> plot(1:2, NotAGraphicalParameter = "ignore.me")
# produces a nice scatterplot with two points, [1,1] and [2,2]
Warning messages:
1: In plot.window(...) :
  "NotAGraphicalParameter" is not a graphical parameter
2: In plot.xy(xy, type, ...) :
  "NotAGraphicalParameter" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
  "NotAGraphicalParameter" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
  "NotAGraphicalParameter" is not a graphical parameter
5: In box(...) : "NotAGraphicalParameter" is not a graphical parameter
6: In title(...) : "NotAGraphicalParameter" is not a graphical parameter
> plot(2:3)
# another nice scatterplot: [2,2] and [3,3] 
# but there should be nothing wrong this time!
# however ...
There were 12 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: "NotAGraphicalParameter" is not a graphical parameter
2: "NotAGraphicalParameter" is not a graphical parameter
3: "NotAGraphicalParameter" is not a graphical parameter
4: "NotAGraphicalParameter" is not a graphical parameter
5: "NotAGraphicalParameter" is not a graphical parameter
6: "NotAGraphicalParameter" is not a graphical parameter
7: "NotAGraphicalParameter" is not a graphical parameter
8: "NotAGraphicalParameter" is not a graphical parameter
9: "NotAGraphicalParameter" is not a graphical parameter
10: "NotAGraphicalParameter" is not a graphical parameter
11: "NotAGraphicalParameter" is not a graphical parameter
12: "NotAGraphicalParameter" is not a graphical parameter
# but let's try once more:
> plot(2:3)
# yup. no warnings this time. we had to do it twice
```
It's like R remembers our insults. But not for long.
I can't really explain why this happens - but it is reproducible. Actually it occurs every time when you supply some "not a graphical parameter" to plot 1, and then do a plot 2 in a completely impeccable way. It is especially funny that we get 12 "not a graphical parameter" warnings for the second plot but only 6 for the first one. Another funny thing is that if you supply "not a graphical parameter" with a value NULL then no condition is thrown:
```
plot(1:2, Nonsense=NULL)
# no warnings
# however
plot(1:2, Nonsense="gibberish")
# gives the usual 6-pack of warnings
```
And to get even more ridiculous, let's draw some lines on top of the previously drawn plot:
```
plot(1:2)
# you will see the number of warnings growing with each line:
lines(1:2, 1:2, mumbo = 1)
lines(1:2, 1:2, jumbo = 2)
lines(1:2, 1:2, bimbo = 3)
lines(1:2, 1:2, cucaracha = 4)
lines(1:2, 1:2, karaoke = 5)
lines(1:2, 1:2, radiogaga = 6)
lines(1:2, 1:2, reptiles = 7)
lines(1:2, 1:2, cowsonmoon = 8)
lines(1:2, 1:2, stainlessSteelLadderToTheMoon = 9)
lines(1:2, 1:2, frambuesa = 10)
lines(1:2, 1:2, fresa = 11)
lines(1:2, 1:2, limonYNada = 12)
lines(1:2, 1:2, slingsAndArrows = 13)
# ... and now you have 25 warnings:
warnings()
Warning messages:
1: "mumbo" is not a graphical parameter
2: "jumbo" is not a graphical parameter
3: "bimbo" is not a graphical parameter
4: "cucaracha" is not a graphical parameter
5: "karaoke" is not a graphical parameter
6: "radiogaga" is not a graphical parameter
7: "reptiles" is not a graphical parameter
8: "cowsonmoon" is not a graphical parameter
9: "stainlessSteelLadderToTheMoon" is not a graphical parameter
10: "frambuesa" is not a graphical parameter
11: "fresa" is not a graphical parameter
12: "limonYNada" is not a graphical parameter
13: "mumbo" is not a graphical parameter
14: "jumbo" is not a graphical parameter
15: "bimbo" is not a graphical parameter
16: "cucaracha" is not a graphical parameter
17: "karaoke" is not a graphical parameter
18: "radiogaga" is not a graphical parameter
19: "reptiles" is not a graphical parameter
20: "cowsonmoon" is not a graphical parameter
21: "stainlessSteelLadderToTheMoon" is not a graphical parameter
22: "frambuesa" is not a graphical parameter
23: "fresa" is not a graphical parameter
24: "limonYNada" is not a graphical parameter
25: In plot.xy(xy.coords(x, y), type = type, ...) :
  "slingsAndArrows" is not a graphical parameter
```
~~This should~~ not ~~win big time unless there is no justice.~~
[Answer]
## Windows Command Script
*WARNING, this is a fork bomb!*
This will output garbage questions about quitting if you try to quit the console in any way.
```
%0|%0|%0
```
Bonuses:
* Will make the system pretty much unusable until restart
* Prevents quitting the script, which should be impossible
[Answer]
How about compiler optimisation errors:
```
#include <stdio.h>
#define N 4
int main(void)
{
    int sum;
    int i;
    int arr[N];
    for (i = 0, sum = 0; i < N; i++, arr[i] = sum) {
        sum += arr[i];
    }
    printf("%d\n", sum);
    return 0;
}
```
This is specific to gcc >= 4.7.
Compiles and runs fine with `gcc -O0 -Wall`.
Compiles with `gcc -O2 -Wall` but results in an inf-loop.
Also note, how gcc does see the problem for smaller `N`, e.g. `N = 3`:
```
test.c:11:38: warning: array subscript is above array bounds [-Warray-bounds]
  for (i = 0, sum = 0; i < N; i++, arr[i] = sum) {
                                       ^
test.c:12:13: warning: 'arr[0]' is used uninitialized in this function [-Wuninitialized]
  sum += arr[i];
         ^
```
Btw, this has been taken from a bug report, I can't recall the bug number though.
[Answer]
# [q](https://en.wikipedia.org/wiki/Q_%28programming_language_from_Kx_Systems%29) insults you
```
q)`u#1 1
'u-fail
q)
```
> 
> ```u#`` tells `q` that every element in a list is unique (so it can build some sort of hash-based index, presumably). this is what happens when it's not actually true.
> 
> 
> 
[Answer]
I've always liked this weirdness in APL:
```
      ⍝ obviously a syntax error
      { (] } 3  
SYNTAX ERROR
      {(]}3
      ⍝ but:
      { (] } 1÷0
DOMAIN ERROR
      {(]}1÷0 
      ⍝ it even works with statically defined functions
      ∇z←f x
[1]  z←[{]}x
[2]  ∇
      f 1÷0
DOMAIN ERROR
      f 1÷0
     ∧
      f 3
SYNTAX ERROR
f[1] z←[{]}x     
```
It parses the inside of functions lazily!
[Answer]
# Python
## Nested blocks
```
for a in range(26):
 for b in range(26):
  for c in range(26):
   for d in range(26):
    for e in range(26):
     for f in range(26):
      for g in range(26):
       for h in range(26):
        for i in range(26):
         for j in range(26):
          for k in range(26):
           for l in range(26):
            for m in range(26):
             for n in range(26):
              for o in range(26):
               for p in range(26):
                for q in range(26):
                 for r in range(26):
                  for s in range(26):
                   for t in range(26):
                    for u in range(26):
                     for v in range(26):
                      for w in range(26):
                       for x in range(26):
                        for y in range(26):
                         for z in range(26):
                          print a
```
Python 2.7: `SystemError: too many statically nested blocks`
## Self-referencing lists
```
def printList(myList):
    for element in myList:
        if isinstance(element, list):
            printList(myList)
        else:
            print(element)
a = []
a.append(a)
printList(a)
```
# Python 2.7
## True is not a constant
The problem in the following example is that in Python 2.7, `True` and `False` are not constants. And `True` and `False` can automatically get casted to `1` and `0`:
```
True=False
a=10/True
Traceback (most recent call last):
  File "/home/moose/.config/pluma/tools/new-tool-2", line 11, in <module>
    exec(sys.stdin.read())
  File "<string>", line 2, in <module>
ZeroDivisionError: integer division or modulo by zero
```
# Python 2.7:
## Intendation
```
def f(n):
    if n <= 1:
        return n
    else:
        return f(n-1)+f(n-2)
```
Do you get the error?
```
Traceback (most recent call last):
  File "/home/moose/.config/pluma/tools/new-tool-2", line 11, in <module>
    exec(sys.stdin.read())
  File "<string>", line 4
    else:
       ^
SyntaxError: invalid syntax
```
Mixing tabs and spaces was ok in Python 2.7 ... but mind the indentation level!
[Answer]
# PHP
```
<?php
[][] = 42;
```
`[]` is used in order to push elements. However, if you use it for array literal, the PHP makes crazy error message, even if you assign to it in order to push. Requires PHP >= 5.4, as before that you couldn't have indexed array literals.
Output:
> 
> **Fatal error**: Cannot use [] for reading in **[...][...]** on line **2**
> 
> 
> 
[Answer]
I'll start:
```
#include <iostream>
using namespace std;
class A
{
public:
    A()
    {
    }
    void doSomethingDiabolical()
    {
        delete this;
    }
    virtual void breakHorribly()
    {
        cout << "still alive" << endl;
        doSomethingDiabolical();
        cout << "still alive" << endl;
    }
};
class B : public A
{
public:
    B() : A()
    {
    }
    void breakHorribly()
    {
        cout << "still alive" << endl;
        ((A *) this)->breakHorribly();
        cout << "still alive" << endl;
        doSomethingDiabolical();
        cout << "still alive" << endl;
        breakHorribly();
        cout << "dead" << endl;
    }
};
int main()
{
    jane();
}
void jane()
{
    cout << "still alive" << endl;
    A * o = new B;
    cout << "still alive" << endl;
    o->breakHorribly();
}
```
Any guesses why this program crashes? :D
See `jane` run: <http://ideone.com/gtaZ3>
[Answer]
## CPython
```
import ctypes
import sys
(ctypes.c_char * sys.getsizeof(None)).from_address(id(None))[:4] = '\x00' * 4
```
The result:
```
Fatal Python error: deallocating None
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
```
[Answer]
# Bash
I got this today when I tried to find out whether it is possible to protect the system from `rm -rf /`.
```
mkdir /tmp/a
mkdir /tmp/a/b
sudo mount --bind /tmp/a /tmp/a/b
rm -rf /tmp/a
```
The error message with `LANG=C`:
```
rm: WARNING: Circular directory structure.
This almost certainly means that you have a corrupted file system.
NOTIFY YOUR SYSTEM MANAGER.
The following directory is part of the cycle:
  '/tmp/a/b'
```
[Answer]
# TeX
This simple TeX program:
```
\def~{x~}~
```
gives the following error in the log file:
```
! TeX capacity exceeded, sorry [main memory size=5000000].
l.1 \def~{x~}~
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
```
You better know which wizard it the right wizard :-) 
---
# TeX: second error message
This is a small LaTeX table with 260 columns, for which we want a cell that spans all the columns.
```
\documentclass{article}
\begin{document}
\begin{tabular}{*{260}{l}}
\multicolumn{260}{c}{Table Title}
\end{tabular}
\end{document}
```
The error message is also hilarious:
```
! This can't happen (256 spans).
<template> \endtemplate 
l.5     \end{tabular}
I'm broken. Please show this to someone who can fix can fix
```
How many programs are humble enough to admit they are broken?
[Answer]
# R
Another one which is not ridiculous and, again, a warning rather than an error, but still nice:
```
> sapply(as.list(-1:-51), log)
 [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
[20] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
[39] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
There were 50 or more warnings (use warnings() to see the first 50)
```
I like the last bit: 50 or more :)
And the actual warnings:
```
1: In lapply(X = X, FUN = FUN, ...) : NaNs produced
2: In lapply(X = X, FUN = FUN, ...) : NaNs produced
....
50: In lapply(X = X, FUN = FUN, ...) : NaNs produced
```
FUN = FUN! 
[Answer]
# Bash - counterintuitive escape failure
```
echo "this should definitely work!!!11!"
```
returns
```
-bash: !11: event not found
```
(history expansion on the commandline is not prevented by double quotes)
## Bonus:
```
echo "I don't know what's gone wrong!! !echo is usually pretty foolproof!-1"
```
The output is unlikely to be what's expected. Press **up** to get the command again, and notice it's changed from what you typed. If you press up and enter a couple of times, it's likely your output will begin to look somewhat horrific. Try it for yourself.
]