\$\begingroup\$

Smalltalk

This creates a new method on the fly, which

creates a new method on the fly, which

creates a new method on the fly, which

...

...

..

and then transfers to it.

An extra little spice comes from stressing stack memory AND heap memory at the same time, by creating both a longer and longer method name, and a huge number as receiver, as we fall down the hole... (but the recursion hits us first).

compile in Integer:

downTheRabbitHole |name deeperName nextLevel| nextLevel := self * 2. name := thisContext selector. deeperName := (name , '_') asSymbol. Class withoutUpdatingChangesDo:[ nextLevel class compile:deeperName , (thisContext method source copyFrom:name size+1). ]. Transcript show:self; showCR:' - and down the rabbit hole...'. "/ self halt. "/ enable for debugging nextLevel perform:deeperName.

then jump, by evaluating "2 downTheRabbitHole" ...

...after a while, you'll end up in a debugger, showing a RecursionException.

Then you have to cleanup all the mess (both SmallInteger and LargeInteger now have a lot of wonderland code):

{SmallInteger . LargeInteger } do:[:eachInfectedClass | (eachInfectedClass methodDictionary keys select:[:nm| nm startsWith:'downTheRabbitHole_']) do:[:each| eachInfectedClass removeSelector:each]

or else spend some time in the browser, removing alice's wonderland.

Here is some from the head of the trace:

2 - and down the rabbit hole... 4 - and down the rabbit hole... 8 - and down the rabbit hole... 16 - and down the rabbit hole... [...] 576460752303423488 - and down the rabbit hole... 1152921504606846976 - and down the rabbit hole... 2305843009213693952 - and down the rabbit hole... [...] 1267650600228229401496703205376 - and down the rabbit hole... 2535301200456458802993406410752 - and down the rabbit hole... 5070602400912917605986812821504 - and down the rabbit hole... [...] 162259276829213363391578010288128 - and down the rabbit hole... 324518553658426726783156020576256 - and down the rabbit hole... [...] and so on...

PS: the "withoutUpdatingChangesFile:" was added to avoid having to cleanup Smalltalk's persistent change-log file afterwards.

PPS: thanks for the challenge: thinking about something new and innovative was fun!

PPPS: I like to note that some Smalltalk dialects/versions copy overflowing stack frames to the heap - so these may run into an out-of-memory situation instead.