Re:Crafting Interpreters with Rust: On Garbage Collection
by jfoutz on Wednesday July 31, 2024 @11:00PM
(#41125778)
True. How would you modify it to get the point across?
Or am I crazy, and there is no point to being careful with alloca?
Re:Crafting Interpreters with Rust: On Garbage Collection
by bombela on Wednesday July 31, 2024 @11:34PM
(#41125898)
Maybe if alloca is used with a runtime value uncapped, a user could then trigger a stack overflow with too big of an allocation. This is the same problem when allocating on the heap, with the difference that the heap is a few order of magnitude larger.
That is really the only difference between `in foo[...N] = ...N` and alloca(n). alloca works with a value computed at runtime. And this value could be from an input.
It will run until it runs out of stack. Or it might just run forever because the compiler optimized it as an infinite loop.
In any case, same behavior.