▲ | Wowfunhappy 5 days ago | ||||||||||||||||||||||||||||||||||
...by that definition, can a C program be memory safe as long as it doesn't have any relevant bugs, despite the choice of language? (I realize that in practice, most people are not aware of every bug that exists in their program.) | |||||||||||||||||||||||||||||||||||
▲ | cibyr 5 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||
Can a C program be memory safe as long as it doesn't have any relevant bugs? Yes, and you can even prove this about some C programs using tools like CBMC. | |||||||||||||||||||||||||||||||||||
▲ | Waterluvian 5 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
This is way outside my domain but isn’t the answer: yes, if the code is formally proven safe? Doesn’t NASA have an incredibly strict, specific set of standards for writing safety critical C that helps with writing programs that can be formalized? | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
▲ | ratmice 5 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
It just seems like a bad definition (or at least ambiguous), it should say "cannot", or some such excluding term. By the definition as given if a program flips a coin and performs an illegal memory access, are runs where the access does not occur memory safe? | |||||||||||||||||||||||||||||||||||
▲ | Ygg2 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
Sure. It can be. In the same way, a C program can be provably correct. I.e., for all inputs it doesn't exhibit unexpected behavior. Memory safety and correctness are properties of the program being executed. But a memory-safe program != memory safe language. Memory safe language helps you maintain memory-safety by reducing the chances to cause memory unsafety. | |||||||||||||||||||||||||||||||||||
▲ | tremon 3 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||
There is a huge difference between "a C program can be memory safe if it is proven to be so by an external static analysis tool" and "the Java/Rust language is memory safe except for JNI resp unsafe sections of the code". |