r/ProgrammingLanguages • u/ThomasMertes • 3d ago
Improved article about memory safety
Thank you to everyone who gave feedback on my article about memory safety.
I used the input to vastly improve the article (see "Achieving memory safety").
Please take a look and share your thoughts again and consider starring the Seed7 project on GitHub.
14
Upvotes
4
u/Athas Futhark 3d ago
Since memory safety is all about avoiding accidental mistakes and also intentional maliciousness from scoundrels, I am going to ask some slightly antagonistic questions:
Does Seed7 restrict IO operations in any way? On many operating systems, if you can do IO, you can read arbitrary memory through various mechanisms (on Linux, via the
/procfilesystem). This is the case for most memory-safe languages and is usually not considered a major problem, but it means you need to be very precise about what exactly Seed7 guarantees. There are languages in which functions absolutely cannot do this, but they tend to be languages that require you to be explicit about IO in the type system. From browsing the Seed7 documentation, it seems conventional in its handling of IO.How does Seed7 deal with circular references and the risk of memory leaks? This is a bit of a trick question, as memory leaks are often defined as not an aspect of memory safety (e.g. Rust programs can leak), but it is still a common memory bug that can lead to program malfunction.
Usually the formal proof is the first step, and only very rarely is the actual implementation proven correct as well. This is because proving an actual implementation correct is significantly more complicated. In fact, even the formal proof for the language definition is usually on a simplified subset. Auditing and testing the implementation (as you do) is of course still a useful activity, and provides a lot of bang-for-the-buck.