7 ms·
C-style stack allocated objects captured by closures are not memory-safe in the absence of escape analysis. If the closure outlives the stack frame that allocat
by barrkel 17y ago
C-style stack allocated objects captured by closures are not memory-safe in the absence of escape analysis. If the closure outlives the stack frame that allocated the object, a dangling pointer may occur, unless the stack frame itself is allocated on the heap, or the captured objects are moved by the compiler into a structure which is itself allocated on the heap.
- dkersten 17y agoExactly, the stack frame needs to survive with the Closure.