libarena::TypedArena::alloc_from_iter does not allow for recursive allocations #67001
Labels
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-high
High priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I stumbled on this while debugging #66936
I tried calling
TypedArena::alloc_from_iter
with an iterator which itself allocates on the arena.If that iterator has fixed size (known through
size_hint
), the allocation goes in the fast path.In that case, the allocation for the range and the recursive allocations get interlaced.
The returned pointers are wrong, and valid objects get overwritten.
This can lead to undropped objects and infinite loops.
A simple fix has been committed to #66936.
A more intelligent one may be better.
The text was updated successfully, but these errors were encountered: