Conversation

Is there a formal definition for what it means for a language to be spatially memory-safe but not temporally memory-safe? Is it something like "memory-safe under the assumption that, once freed, that memory block (whether heap or stack) will never be reused"?
11
30
Replying to
I don't really see how you can have one without the other. If you reduce the size of a dynamic array from 2M to 1M in-place and then access beyond 1M due to lack of temporal safety that looks a lot like an out-of-bounds access to me. They're not really cleanly separated things.
3
3
Replying to and
Hmm. spatial safety: all accesses are to memory that has been allocated? temporal safety: no accesses to memory that has been deallocated? C - neither Java - both (excluding the evil low-level API)
2
Replying to and
boost::variant - I viscerally hate incoming pointers - arguably the problem is the "references to the inside" *aren't* invalidated. Seems similar to pascal variants: temporal not spatial? std::shared_ptr - don't know recent C++. if they empty the pointer, spatial not temporal?
1
Replying to and
std::shared_ptr is an atomically referenced counted pointer managing the lifetime of what's inside. I was using it as an example of safely sharing a reference across threads and then having a data race on what's inside: appending to a dynamic array with no locking.
Replying to and
but really I'd prefer to say that the second case is a question of "thread safety" *not* "memory safety" - assuming the point of all this is to come up with fine but meaningful definitions what does say? He'd know!
2
Show replies