Call Stack Alternatives

Discussions focus on the use of stacks for function calls in compilers like C, stack overflows versus smashing, and alternatives such as heap-allocated frames, growable or segmented stacks, and stackless implementations.

➡️ Stable 0.5x Programming Languages
4,178
Comments
20
Years Active
5
Top Authors
#1261
Topic ID

Activity Over Time

2007
2
2008
5
2009
44
2010
72
2011
88
2012
75
2013
132
2014
175
2015
178
2016
258
2017
254
2018
328
2019
284
2020
299
2021
481
2022
380
2023
389
2024
345
2025
353
2026
38

Keywords

RAM stdio.h CPU OP FORTRAN IR XC8 SMTP ABI LLVM stack heap function registers int return variables stacks compiler memory

Sample Comments

FranchuFranchu May 27, 2021 View on HN

The way most C compilers and ABIs use the stack kills it imo. But you could tweak a compiler to change that.

jcdavis Oct 3, 2011 View on HN

Sure it is. Stack space isn't free

ganafagol Jan 8, 2021 View on HN

The C standard does not mention a stack. One can implement a C compiler that puts activation records on the heap or does other magic to avoid a stack that can overflow. A call stack is an implementation detail. Expecting it to exist or not exist is assuming things about the compiler. Those assumptions may be reasonable but are not part of the semantics of the language itself. They are about particular properties of your compiler.

saagarjha Aug 5, 2022 View on HN

They can overflow the stack. They cannot smash the stack.

crististm Jul 13, 2018 View on HN

Function calls don't necessarily need to use stacks. There is nothing preventing frame allocations on heap.

nine_k Apr 18, 2019 View on HN

Would the segmented stack of the early Go implementations be helpful in such a case?

duped Mar 14, 2025 View on HN

If we had standardized growable call stacks then this wouldn't happen

ww520 Dec 9, 2014 View on HN

Stack was pretty small. Allocating structure on the heap instead of on the stack is pretty standard. We just need to understand the historic context before making judgement.

willtim Nov 15, 2017 View on HN

The runtime could allocate "stack frames" on the heap, for such cases.

xiaq Jul 13, 2018 View on HN

Function calls use stacks. It is not the same thing as heap allocation.