Remix.run Logo
thayne 8 hours ago

> All elements remain valid at all times. free does not release any memory and does not end any lifetime — it adds an index to a freelist. The slot is still a live, well-typed Item afterwards, and it still belongs to the pool, which still belongs to its owning scope. > > So there is nothing here to be unsafe. A reference to a freed-and-reused slot reads a different Item — a perfectly good one, just not the one you were thinking of.

This avoids the dreaded undefined behavior, but it can still be pretty bad. For example, accessing a record that has been freed and re-used could leak sensitive information from one user to another. Granted that kind of bug is possible with any memory safe language, but this pattern is probably more like to be used in goose than languages with automated memory management.