# Shortest program that throws StackOverflow Error [closed]

Write a program that throws a StackOverflow Error or the equivalent in the language used. For example, in java, the program should throw java.lang.StackOverflowError.

You are not allowed to define a function that calls itself or a new class(except the one containing main in java). It should use the classes of the selected programming language.

And it should not throw the error explicitly.

• I don't understand "use the classes of the selected programming language" – Prince John Wesley Jan 4 '13 at 15:07
• Is it ok to define a function that calls inner function like this def s{def t=s;t} ? – Prince John Wesley Jan 4 '13 at 15:10
• In most languages, classes are only a special kind of data structure, not the center of the universe. Many don't even have such a thing. – ceased to turn counterclockwis Jan 4 '13 at 21:42
• The funny thing here is that languages that require tail recursion elimination (and implementations that support it when the languages does not require it)---which are in a very real sense better---are at a disadvantage on this. TwiNight's answer links to the version of this that exists on Stack Overflow from the early days. – dmckee --- ex-moderator kitten Jan 4 '13 at 22:13
• From the java doc: Thrown when a stack overflow occurs because an application recurses too deeply. docs.oracle.com/javase/6/docs/api/java/lang/… – jsedano Apr 9 '13 at 16:24

# Befunge, 1

I don't know Befunge, but...

1


from Stack overflow code golf

• Explanation: 1 is a numeric literal that gets pushed to the stack when encountered. In Befunge, control flow wraps around until it encounters an @ to end the program. – histocrat Jan 4 '13 at 17:30
• I didn't know there was this question on StackOverflow. I searched only on this site before posting. – True Soft Jan 5 '13 at 8:26
• I'm mildly flattered to see my answer here. – Patrick Apr 9 '13 at 1:50
• This works in ><> too. – Cruncher Nov 6 '13 at 15:09

### Python (2.7.3), 35 characters

import sys
sys.setrecursionlimit(1)


This operation itself succeeds, but both script and interactive will immediately throw RuntimeError: 'maximum recursion depth exceeded' afterward as a consequence.

• I thought about putting that up as my solution instead, but wasn't sure if the error could be considered a stack overflow. Though, essentially, that is what it is, right? – elssar Jan 5 '13 at 8:25
• @elssar: I guess there are two ways to overflow the stack: make the used part of the stack larger, or make the unused part of the stack smaller. If you imagine a bucket filling with water, you can overflow it by adding more water, but you can also overflow it by shrinking the bucket. – user62131 Jun 2 '17 at 14:51

## Coq

Compute 70000.


70000 is just syntactic sugar for S (S ( ... (S O) ...)) with 70000 S's. I think it's the type checker that causes the stack overflow.

Here's a warning that is printed before the command is executed:

Warning: Stack overflow or segmentation fault happens when working with large
numbers in nat (observed threshold may vary from 5000 to 70000 depending on
your system limits and on the command executed).

• That might let you think Coq is an incredibly dumb language... funny... – ceased to turn counterclockwis Jan 6 '13 at 13:01
• @leftaroundabout Actually not. The Nat type is a type level peano numeral that must act as if it is a linked list. – FUZxxl Jan 6 '13 at 15:40
• @FUZxxl: my comment was not not meant ironically at all. Decide for yourself if you want to include classical logic into that sentence, or prefer to stay constructive... – ceased to turn counterclockwis Jan 6 '13 at 20:42
• @leftaroundabout Oops... sorry. I forgot that the markdown parser always eats those nice &lt;irony&gt;-tags. – FUZxxl Jan 6 '13 at 21:28

# Java - 35

class S{static{new S();}{new S();}}

• Didn't OP say no new classes? I don't see a public static void main in there. Or am I just failing to understand Java? – Braden Best Feb 5 '14 at 19:17
• @B1KMusic There are no new classes, there's only one class (S). The code uses a static initializer, it throws the SO before the jvm figures out there's no main method. Works with java 6. – aditsu quit because SE is EVIL Feb 5 '14 at 20:20
• I understand the static block. But what is the next block ? – Nicolas Barbulesco Jun 7 '14 at 20:51
• @NicolasBarbulesco That's an initializer block, it's executed when you construct a new instance. – aditsu quit because SE is EVIL Jun 8 '14 at 6:41
• @LuigiCortese I think it only works with java 6 or older – aditsu quit because SE is EVIL Jul 25 '15 at 22:12

## Javascript 24 characters

Browser dependent answer (must have access to apply):

eval.apply(0,Array(999999))

• eval was the shortest global function name that I could find (anyone know of one that is shorter?)
• apply allows us to convert an array into function parameters, the first parameter being the context of the function (this)
• Array(999999) will create an array with the listed length. Not sure what the maximum number of arguments is, but it's less than this, and more than 99999

IE9:

SCRIPT28: Out of stack space
SCRIPT2343: Stack overflow at line: 20


Chrome 24:

Uncaught RangeError: Maximum call stack size exceeded


FireFox 18

RangeError: arguments array passed to Function.prototype.apply is too large


Note — Due to the single threaded nature of javascript, infinite loops end up locking the UI and never throwing an exception.

while(1);
for(;;);


Neither of these qualify.

Update — this shaves off three characters:

eval.apply(0,Array(1e7))

• MDN says that eval is the shortest. – Peter Taylor Jan 23 '13 at 13:30
• eval.apply(0,Array(1e6)) saves 3 chars, you can even go with 9e9 at no cost – ThinkChaos Feb 2 '14 at 22:30
• apply is a standard ECMAScript feature. There is nothing browser dependent. Unless you are talking about really old browsers, but this wouldn't work in hypothetical Netscape 2 with apply anyway, because Array class doesn't exist in Netscape 2. – Konrad Borowski Apr 2 '14 at 12:02
• new shortest in ES6: eval(...Array(9e9)) – Patrick Roberts Jan 25 '16 at 7:36
• Probably non-standard, throws in Chrome from the console. dir.apply(0,Array(1e7)); – Paul J Nov 21 '16 at 22:05

# Python 2.7 (12 chars)

exec('{'*99)


results in a «s_push: parser stack overflow»

• I get SyntaxError: unexpected EOF while parsing – Martin Thoma Jan 14 '13 at 7:15
• With exec('{'*101) I get MemoryError – Martin Thoma Jan 14 '13 at 7:15
• In Python2, exec is a statement, so you can just use exec'{'*999 (99 doesn't seem to be enough) – gnibbler Feb 3 '14 at 1:15
• You need at least 100 to trigger a MemoryError. And that ≠ stack overflow – noɥʇʎԀʎzɐɹƆ Sep 12 '16 at 23:39

# Mathematica, 4 chars

x=2x


$RecursionLimit::reclim: Recursion depth of 1024 exceeded. >> • "You may not define function that calls itself" – Tomas Feb 2 '14 at 16:03 • That isn't a function, it's a variable (unless it isn't at all what it looks like). – A.M.K Feb 3 '14 at 3:12 • You took my idea. – PyRulez Apr 16 '14 at 21:09 Clojure, 12 chars (#(%%)#(%%))  Running in the repl: user=> (#(%%)#(%%)) StackOverflowError user/eval404/fn--407 (NO_SOURCE_FILE:1)  • This reminds me of the lambda calculus expression (\x.xx)(\x.xx), but I don't know clojure well enough to tell for sure if this is what's happening. I also don't see why the aforementioned expression would result in a stack overflow, so maybe you're doing some trickery with the Y-combinator? This answer interests me and an explanation would be nice. – Zwei Sep 10 '16 at 19:26 # Java - 113 chars I think this stays within the spirit of the "no self-calling methods" rule. It doesn't do it explicitly, and it even goes through a Java language construct. public class S { public String toString() { return ""+this; } public static void main(String[] a) { new S().toString(); } }  Condensed Version: public class S{public String toString(){return ""+this;}public static void main(String[] a){new S().toString();}}  • Well, ""+this is actually ""+this.toString(), so the method calls itself. – True Soft Jan 19 '13 at 8:08 • @TrueSoft Pretty sure java throws in a StringBuilder object there. toString will likely be called from within there. – Cruncher Feb 18 '14 at 21:48 • By the time the compiler and optimizer are done, the toString() method ends up being public java.lang.String toString() { return this.toString(); } – Jonathan Callen Feb 23 '14 at 19:38 # C, 19 bytes main(){int i[~0u];}  • @Thomas Yes it is a stack overflow on any machine where local variables are allocated on the stack. Since the C language has no concept of a stack overflow indication (it's all undefined behavior; one of them manifests itself as a segfault), this does fit the original requirement. – Jens Feb 2 '14 at 17:45 • OK, sorry, accepted. – Tomas Feb 2 '14 at 17:49 • it gives main.c:1:16: error: size of array 'i' is negative for me on gcc 4.8.1. The unsigned version main(){int i[~0U];} works. – Csq Feb 25 '14 at 16:00 • Doesn't work for me after I manually configured a 4GB stack. – FUZxxl Oct 6 '15 at 12:58 • @FUZxxl Interesting; are your ints 32 bit? If so, sizeof(i) is 16GB. Does using an ul or ull suffix make a difference? Some systems over-commit memory and only crash if the memory is written to. – Jens Oct 6 '15 at 16:47 ## GolfScript (8 chars) {]}333*  Result: $ golfscript.rb overflow.gs
golfscript.rb:246:in initialize': stack level too deep (SystemStackError)
from /home/pjt33/bin/golfscript.rb:130:in new'
from /home/pjt33/bin/golfscript.rb:130:in ginspect'
from /home/pjt33/bin/golfscript.rb:130:in ginspect'
from /home/pjt33/bin/golfscript.rb:130:in map'
from /home/pjt33/bin/golfscript.rb:130:in ginspect'
from /home/pjt33/bin/golfscript.rb:130:in ginspect'
from /home/pjt33/bin/golfscript.rb:130:in map'
from /home/pjt33/bin/golfscript.rb:130:in ginspect'
... 993 levels...
from (eval):4
from /home/pjt33/bin/golfscript.rb:293:in call'
from /home/pjt33/bin/golfscript.rb:293:in go'
from /home/pjt33/bin/golfscript.rb:485


Basically this creates a heavily nested data structure and then overflows the stack when trying to turn it into a string.

• For me, this doesn't throw an error, but outputs [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[[[[[[[""]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] ]]]]]]]]]]]]]]]]] (and so on, output too long for comments) – ProgramFOX Feb 2 '14 at 16:30
• @ProgramFOX, there will be some value which you can replace 333 with and it will break. 333 was the smallest value which broke for me, but if you have a different version of Ruby (or maybe the same version on a different OS, for all I know) it might handle a different number of stack frames before overflowing. – Peter Taylor Feb 2 '14 at 22:54
• Breaks at 3192 on my machine, so 6.? still works without adding characters. – Dennis Jun 26 '14 at 22:53

# x86 assembly, NASM syntax, 7 bytes

db"Pëý"


"Pëý" is 50 EB FD in hexadecimal, and

_loop:
push eax
jmp _loop


in x86 assembly.

## Ruby, 12

eval"[]"*9e3


Gives

SystemStackError: stack level too deep


Presumably system-dependent, but you can add orders of magnitude by bumping the last digit up (not recommended).

Edit for explanation: Similarly to some other examples, this creates a string of [][][]...repeated 9000 times, then evaluates it: the rightmost [] is parsed as a function call to the rest, and so on. If it actually got to the beginning, it would throw an ArgumentError because [] is an object with a [] method that requires one argument, but my machine throws an error a little before the stack is over nine thousand.

• hmm... crashed IRB :P – Doorknob Mar 22 '13 at 23:35
• Which version? ruby 1.9.2 throws “ArgumentError: wrong number of arguments (0 for 1..2)”. – manatwork Jun 1 '13 at 11:24
• Found an old ruby 1.8.7. There the posted code works as described. – manatwork Jun 1 '13 at 11:58
• Odd, it works on my 1.8.7, 1.9.2, and 1.9.3. – histocrat Jun 3 '13 at 12:24
• I would have said def f;f;end;f – EMBLEM May 6 '15 at 19:32

# Rebol (11 Chars)

do s:[do s]


Yields:

>> do(s:[do s])
** Internal error: stack overflow
** Where: do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do
do do do do do do do do do do do do...


Though Rebol has functions, closures, and objects...this doesn't define any of those. It defines a data structure, which in the code-as-data paradigm can be treated as code using DO.

We can probe into the question of "what is S" with the REPL:

>> s: [do s]
== [do s]

>> type? s
== block!

>> length? s
== 2

>> type? first s
== word!

>> type? second s
== word!


DO never turns this into a function, it invokes the evaluator in the current environment on the structure.

• +1 ... I hadn't noticed that my answer was defining a function and that was against the rules, but edited my answer to use DO...then noticed you'd already submitted that answer. So I just deleted mine, but since I'd written up why this isn't defining an object/function/closure I thought I'd put the explanation into yours. Also I think the do do do do is kind of funny and worth including. :-) Hope that's ok! – HostileFork says dont trust SE Apr 16 '14 at 20:44

# C, 35 characters

main(){for(;;)*(int*)alloca(1)=0;}

• Why store anything in the assigned space? – Peter Taylor Jan 5 '13 at 17:15
• In this case, it's impossible to solve this problem in C. – FUZxxl Jan 6 '13 at 15:41
• @dmckee, Not all segmentation faults are stack overflows, but I'd say this one is, since it's the result of exceeding the stack capacity. – ugoren Jan 6 '13 at 19:12
• @dmckee, alloca allocates from the stack. – ugoren Jan 6 '13 at 19:15
• @PeterTaylor: It probably depends on the implementation but in my case alloca(1) is basically translated to sub $1, %esp so the stack isn't touched. – Job Jan 7 '13 at 14:48 # Common Lisp, 7 characters #1='#1#  • Beautiful...I was planning to use #1=(#1#) for the terminal and (print #1=(#1#)), but your solution is so much better. – protist Nov 19 '13 at 16:29 • Actually that doesn't overflow at read time, only when you attempt to print it. So aside from the 1 character difference, yours is no better. – protist Nov 19 '13 at 16:31 • You're right, just edited that out. I'm not sure if there's a way to cause an overflow at read-time. – Erik Haliewicz Jan 11 '14 at 22:04 • Actually, #.#1='#1# causes a read-time overflow :-) – Erik Haliewicz Apr 27 '14 at 22:26 ## Python - 11 chars exec'('*999  >>> exec'('*999 s_push: parser stack overflow Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError  • Very clever solution. – mbomb007 Feb 24 '15 at 14:54 # Casio Calculator, 11 keypresses It's quite hard to count bytes/tokens in this "language" - I've given the number of keypresses required, excluding Shift, Alpha (the second shift key) and = at the end - this certainly fits into 1 byte per keypress. Tested on the fx-85GT PLUS model, which is a standard, non-graphing, "non-programmable" scientific calculator. Other models will work. Just stack up 11 cube roots: 3√ 3√ 3√ 3√ 3√ 3√ 3√ 3√ 3√ 3√ 3√ It doesn't even give a syntax error about the missing number under the square root. This doesn't seem to work with square roots. Alternatively, repeat cos( 31 times. ## Output Stack ERROR [AC] :Cancel [<][>]:Goto  I believe that this qualifies as a stack overflow. The stack seems to be tiny... • I always thought it was called stack error because you "stacked up" too many roots :P – FlipTack Nov 21 '16 at 15:13 • My Canon calculator gives a stack error with just about any operator (excluding at least +, -, * and /) if it is repeated 25 times or more. For instance, this causes stack error (without syntax error): ((((((((((((((((((((((((( – Steadybox Dec 3 '16 at 19:13 # FORTH, 13 bytes BEGIN 1 AGAIN  overflows the value stack • : X X ; X (9) must overflow return stack – AMK Jan 18 '13 at 14:45 • won't work (X isn't defined while defining the call and that's a self reference/recursion – ratchet freak Jan 18 '13 at 14:50 • @ratchetfreak, those control words can only be used in a compile state, so they need to be wrapped in a :...; word definition. That adds at least 6 characters, plus at least 2 more for this to execute as a program. You might be able to do it shorter, but here's an example: : F BEGIN 1 AGAIN ; F. I suggest this because the question asks: "Write a program." Anyways, gave you an upvote for Forth, regardless of char count! :-) – Darren Stone Jan 4 '14 at 18:08 # Postscript, 7 {1}loop  Eg. $ gsnd
GPL Ghostscript 9.06 (2012-08-08)
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>{1}loop
Error: /stackoverflow in 1
Operand stack:
--nostringval--
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue
Dictionary stack:
--dict:1168/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 8
GS<1>


main=print$sum[1..999999]  sum is lazy in the total. This piles up a bunch of thunks, then tries to evaluate them all at the end, resulting in a stack overflow. ## PHP 5.4, 33 characters for($n=1e5;$n--;)$a=(object)[$a];  This causes a stack overflow when the nested stdClass objects are automatically destroyed: $ gdb -q php
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
(gdb) set pagination 0
(gdb) r -nr 'for($n=1e5;$n--;)$a=(object)[$a];'
Starting program: /usr/bin/php -nr 'for($n=1e5;$n--;)$a=(object)[$a];'

Program received signal SIGSEGV, Segmentation fault.
0x00000000006debce in zend_objects_store_del_ref_by_handle_ex ()
(gdb) bt
#0  0x00000000006debce in zend_objects_store_del_ref_by_handle_ex ()
#1  0x00000000006dee73 in zend_objects_store_del_ref ()
#2  0x00000000006a91ca in _zval_ptr_dtor ()
#3  0x00000000006c5f78 in zend_hash_destroy ()
#4  0x00000000006d909c in zend_object_std_dtor ()
#5  0x00000000006d9129 in zend_objects_free_object_storage ()
#6  0x00000000006dee53 in zend_objects_store_del_ref_by_handle_ex ()
#7  0x00000000006dee73 in zend_objects_store_del_ref ()
#8  0x00000000006a91ca in _zval_ptr_dtor ()
#9  0x00000000006c5f78 in zend_hash_destroy ()
#10 0x00000000006d909c in zend_object_std_dtor ()
#11 0x00000000006d9129 in zend_objects_free_object_storage ()
[...]
#125694 0x00000000006dee53 in zend_objects_store_del_ref_by_handle_ex ()
#125695 0x00000000006dee73 in zend_objects_store_del_ref ()
#125696 0x00000000006a91ca in _zval_ptr_dtor ()
#125697 0x00000000006c5f78 in zend_hash_destroy ()
#125698 0x00000000006d909c in zend_object_std_dtor ()
#125699 0x00000000006d9129 in zend_objects_free_object_storage ()
#125700 0x00000000006dee53 in zend_objects_store_del_ref_by_handle_ex ()
#125701 0x00000000006dee73 in zend_objects_store_del_ref ()
#125702 0x00000000006a91ca in _zval_ptr_dtor ()
#125703 0x00000000006c4945 in ?? ()
#125704 0x00000000006c6481 in zend_hash_reverse_apply ()
#125705 0x00000000006a94e1 in ?? ()
#125706 0x00000000006b80e7 in ?? ()
#125707 0x0000000000657ae5 in php_request_shutdown ()
#125708 0x0000000000761a18 in ?? ()
#125709 0x000000000042c420 in ?? ()
#125710 0x00007ffff5b6976d in __libc_start_main (main=0x42bf50, argc=3, ubp_av=0x7fffffffe738, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe728) at libc-start.c:226
#125711 0x000000000042c4b5 in _start ()

• +1 for what must be PHP's second appearance on CodeGolf! – Bojangles Apr 11 '13 at 13:53

# Q/k (16 chars)

Not sure if this is in the spirit of the challenge but I don't think it breaks the rules:

s:{f};f:{s};f

• It's a shame C# requires so much typing, you inspired my answer! – Andrew Gray Apr 8 '13 at 18:59

A bunch in the same style:

## Python, 30

(lambda x:x(x))(lambda y:y(y))


## Javascript, 38

(function(x){x(x)})(function(y){y(y)})


## Lua, 44

(function(x) x(x) end)(function(y) y(y) end)

• In Python x=lambda y:y(y);x(x) is shorter (20 chars). This function is not recursive. x calls any function passed to it as an argument. – AMK Apr 17 '13 at 16:28
• Ruby 2.0 - ->x{x[x]}[->y{y[y]}] – John Dvorak Nov 1 '13 at 12:10
• Mathematica #@#&[#@#&] – alephalpha Nov 13 '13 at 14:57
• You're just using recursion, then why not do just that, for example in JS: (function x(){x()})() ? – xem Jan 1 '14 at 14:29
• @xem Requirements say no recursion, that is why. – Danny Feb 14 '14 at 13:16

# C#: 10686584632 28

32: Getters can SO your machine easy in C#:

public int a{get{return a;}}

• No need for setter public int a {get{return a;}} – Mike Koder Apr 10 '13 at 10:35
• This violates the rule "You are not allowed to define a function which calls itself". Admittedly it's hidden behind syntax sugar, but it's still missing the point of the challenge. – Peter Taylor Apr 11 '13 at 13:08
• Adding the setter somewhat circumvents the rule, because you now have two functions calling each other. But I wonder: does that still violate the OP's intentions behind this challenge? – Andrew Gray Apr 11 '13 at 13:10
• The idea as I understand it is to find some excessively nested recursion in the interpreter or standard API of the language. This might not be too easy in C#. – Peter Taylor Apr 13 '13 at 21:21
• Why "public string"? "int" works just as well: int a { get { return a; } } – NPSF3000 Nov 9 '13 at 11:16

# LaTeX: 8 characters

\end\end


This is the same code used in this answer. Essentially, the \end macro expands itself repeatedly, resulting in a stack overflow: TeX capacity exceeded, sorry [input stack size=5000]. A more detailed explanation can be found here.

# INTERCAL, 12 bytes

(1)DO(1)NEXT


## Explanation:

NEXT is INTERCAL's version of a subroutine call (or, at least, the closest you can get). It pushes the current position onto the NEXT stack and jumps to the given label.

However, if the NEXT stack length exceeds 80, you get what's pretty much the INTERCAL version of a stack overflow:

ICL123I PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON
ON THE WAY TO 1
CORRECT SOURCE AND RESUBNIT

• "HAS DISAPPEARED INTO THE BLACK LAGOON" what is this, ArnoldC? – Addison Crump Jan 24 '16 at 12:28

# Mornington Crescent, 139 133

Take Northern Line to Bank
Take Circle Line to Temple
Take Circle Line to Temple
Take Circle Line to Bank
Take Northern Line to Angel


# X86 assembly (AT&T), 33 characters

Note that although I'm using the label main as a jump target, this is not a recursive function.

.globl main
main:push \$0;jmp main

• Nice idea: this is a sort of recursion-without-recursion! – Andrea Corbellini Jan 9 '13 at 21:29
• using a86: dd 0fdeb60 10 characters! – Skizz Jan 15 '13 at 16:17

# Python (17):

c='exec c';exec c

• hm, I get KeyError: 'unknown symbol table entry'` – stefreak Dec 12 '17 at 22:50