this post was submitted on 12 Sep 2025
438 points (98.9% liked)

Programmer Humor

26299 readers
1385 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] HappyFrog@lemmy.blahaj.zone 44 points 1 day ago (2 children)

Will this ever return? Won't it just overflow the stack?

[–] sjmarf@sh.itjust.works 75 points 1 day ago (4 children)

Yep, this will cause a stack overflow.

[–] rovingnothing29@lemmy.world 28 points 1 day ago

A mod will appear in my office and claim my problem is a duplicate when it's not?

[–] Mad_Punda@feddit.org 25 points 1 day ago* (last edited 1 day ago)

Might very well be an endless loop because tail recursion can be optimized to reuse the stack frame. Depends on a lot of things of course.

[–] MonkderVierte@lemmy.zip 2 points 1 day ago* (last edited 1 day ago) (2 children)

~~Hm, stack overflow is basically a forkbomb in programming?~~ ok, bullshit.

[–] orhtej2@eviltoast.org 21 points 1 day ago

Forkbomb kills the entire system so not really.

With the stack overflow the runtime will gracefully terminate the program.

[–] calcopiritus@lemmy.world 11 points 1 day ago* (last edited 1 day ago) (1 children)

No.

A stack overflow is a symptom, not the illness. A fork bomb is an illness.

Software coming from the mathematical point of view, assummes it has infinite resources. However, a real computer has many resources that are finite.

CPU time is finite. Memory amount is finite. There is a finite number of network ports. And so on.

A stack overflow just means: "you have run out of this resource called 'the stack'". The stack is a region of the memory. Each thread of each process has 1 stack, and it is not infinite in size. This program will cause a stack overflow because it is infinitely recursive, and each function call will consume a bit of the stack.

A forkbomb is not the end of a finite resource. A fork bomb is a program that uses "forking" to rapidly consume system resources. A fork bomb might cause a stack overflow. Or an out of memory issue. Slow the computer a lot. Or if the OS has a hard limit for process amount, it might reach that limit.

[–] davidgro@lemmy.world 1 points 1 day ago

A program such as the one in this post is a loop designed (intentionally or not) to run out of stack regardless of how much there is. I'd call that an illness rather than a symptom.

[–] Valmond@lemmy.world 1 points 1 day ago

Program it with template meta programming and cause a stack overflow when compiling 🤓😎