4 ms·
> Of course it's possible. If your issue is memory checking you can use mudflap or valgrind. It might be theoretically possible but in practice nobody has mana
by letstryagain 12y ago
> Of course it's possible. If your issue is memory checking you can use mudflap or valgrind.
It might be theoretically possible but in practice nobody has managed to do so with any non-trivial application.
- semi-extrinsic 12y agoI beg your pardon? I've used valgrind for this purpose on large scientific codes running with MPI on supercomputers. And that works fine. The PETSc team at Argonne National Lab, who write perhaps the most used high-performance parallell linear algebra library in existence in C use valgrind for debugging. Surely those count as non-trivial applications?
- dllthomas 12y agoI think the parent was trying to say "no one has managed to use C safely in a non-trivial application", not "no one has managed to use mudflap or valgind on a nontrivial application".
- ars 12y agoHe could try to say that, but it doesn't make him correct. And in fact if someone used valgrind and fixed any errors (which plenty of people have done successfully) that completely disproves him. He should retract his false statement due to evidence against it.
- dllthomas 12y agoI didn't say anything about whether either was correct. I simply was trying to help people avoid talking past each other, because the parent seems to be addressing something the grandparent didn't say. People have unquestionably used Valgrind to find errors, in trivial and nontrivial applications. The question here is whether the result is "safe code". It may be, but the parent does not seem to be speaking to that question, hence my attempt at clarification.
- ars 12y agoI understood you, I was replying to the thread in general. > ... the result is "safe code". It may be, but the parent does not seem to be speaking to that question ... Here we differ. The ability to successfully run valgrind (and presumably remove all errors) does actually speak to the question, and it answers that the result is in fact safe code. It is not necessary for the compiler to assure safe code, it's perfectly possible to do it with an external tool. And as a result C is a safe language as long as you use both tools.
- dllthomas 12y agoIf we presume "... and remove all errors" (and this can be done reliably), then yes that is speaking directly to the question and you have safe code. I would be surprised if the comment I replied to had intended to be asserting that, though. If that is what they intended, it would have been good for them to be more explicit about what amounts to the strongest claim made in the comment.
- deleted 12y ago[deleted]
- dagw 12y agoHPC code is trivially 'easy' to write from this perspective. You mainly 'only' have to worry about memory leaks, dead locks or overflows on valid or accidentally miss-formated data. It's not like an army of world class hackers are pouring over your code looking for vulnerabilities to exploit. Nor that someone will intentionally try to craft input that will crash your application.
- ars 12y agoIf you ran valgrind (and mudflap) then any error that might be detected by a compiler with range checking will be detected. Any further errors will not be fixed by any supposed "safe" language either. Imagining that another language will make a difference is a mistake. It will not.
- pjmlp 12y agoAssuming such tools exist for a specific OS, and not only UNIX flavours.
- dllthomas 12y agoStrictly, "... or that you can run your tests on an OS that does, and your code does not behave meaningfully differently between OSes." Either way, it may or may not be a strong assumption, depending on domain...
- dllthomas 12y ago"If you ran valgrind (and mudflap) then any error that might be detected by a compiler with range checking will be detected." Only if you can be sure you have touched all the interesting portions of input-space. Ideally your tests are doing this, but wherever your tests miss aren't covered by valgrind or mudflap but are covered by a change of language. That's a part of what's meant by safe. It's not that it's impossible to write correct code in an unsafe language. It's that it's difficult to impossible to verify that you have written correct code. I'm very willing to include available tools in that calculation, but valgrind and mudflap (while tremendously useful) cannot give guarantees.