r/ProgrammingLanguages • u/ThomasMertes • Oct 14 '26
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.
13
Upvotes
View all comments
Show parent comment
1
u/ThomasMertes Oct 14 '26 edited Oct 14 '26
Depending on how you opened a file reading or writing might not be allowed and attempting to do so will trigger the exception FILE_ERROR. Beyond this, there are no restrictions.
This wasn't on my radar. I expected that operating system privileges would handle that, but this seems not to be the case. I asked Google AI and got:
I need to consider that.
How is this done?
I can imagine that the functions that open a file, look at the path and fail if the memory of the own process is requested. But this is operating system specific and it might not be easy to make it 100% correct.
Maybe it is possible to tell the OS that accessing the own memory should not be allowed for the current process. I saw that on Linux there is prctl() and seccomp(). Maybe these can be used.
Contrary to languages with pointers, Seed7 was not designed to support implementing low-level data structures such as linked lists. So instead of using pointers to create e.g. linked lists Seed7 proposes using container types like array and hash to build complicated data structures.
That said, circular references could lead to memory leaks. BTW., neither the Seed7 example programs nor the Seed7 run-time libraries contain any circular reference.
When using a programming language the memory safety of the actual implementation is what counts. It does not help if a language is formally proven to be memory safe if it is not in practice.