3 ms·
> It is possible to write provably correct code. ... and then someone finds a bug in the specification which is provably correctly implemented. Using gets() t
by kazinator 11y ago
> It is possible to write provably correct code.
... and then someone finds a bug in the specification which is provably correctly implemented.
Using gets() to read the input can be provably correct. All you have to do is remove any requirements for security from the program's specification, and specify that the program will always be used in circumstances when the expected input datum will be less than a certain length.
... and then the hardware is buggy or failing. That RAM bit flips and you're screwed. The machine as a whole isn't provably correct.
- Avshalom 11y agoCosmic rays are no excuse not to throw an exception on integer overflow.
- kazinator 11y agoIf, for some inputs, the program is supposed to calculate the value 42, but it throws an integer overflow, then it is not correct. Detecting overflows and throwing nice exceptions instead of continuing execution with garbage values isn't the same thing as ensuring correctness.
- ealloc 11y agoIs it really the case that some programming languages are more resilient to hardware errors than others? Java does array bounds checking in principle, but it is usually optimized out of the machine code. Isn't it then virtually just as susceptible to hardware error as C? And the JVM is written in C anyway.
- kazinator 11y agoThis has been the subject of some papers, like https://www.cs.princeton.edu/~appel/papers/memerr.pdf https://www.cs.princeton.edu/~appel/papers/memerr.pdf [2003]
- lmm 11y agoThe JVM is written in C, but that C has been subject to some formal analysis. And even if it hadn't, I'd bet the defect rate of a Java program running on a C JVM would be much much lower than that of a C program.
- kazinator 11y agoBut, in keeping with this topic, that C has not been subject to formal analysis from the angle of defending against rays doing random things to the CPU and RAM or other hardware errors.
- unscaled 11y agoSo let's stop unit testing all of our code, since it's provably incorrect anyways, due to cosmic rays flipping random bits of RAM once in every gazillion calculations.
- pjmlp 11y ago> And the JVM is written in C anyway. Which one? https://en.wikipedia.org/wiki/List_of_Java_virtual_machines https://en.wikipedia.org/wiki/List_of_Java_virtual_machines Depending which one we are speaking about, they are implemented in Assembly, C, C++ or even Java.
- catnaroek 11y ago> ... and then someone finds a bug in the specification which is provably correctly implemented. As a programmer, if the specification is wrong, it's Not My Fault (tm). If you want me to write specifications, well, pay me to do it! I guarantee dramatically better results than the usual crap. > The machine as a whole isn't provably correct. As a programmer, defects in the machine are Not My Problem (tm). In any case, hardware vendors have a much better track record than software developers at delivering products that meet strict quality standards.
- kazinator 11y agoUnfortunately, even if it's not your fault or problem, there is a fault or problem. We're no longer discussing correctness, but assignment of blame.
- catnaroek 11y agoAssignment of blame is important, because it determines what component needs to be fixed to solve the problem. It's all about correctness in the end. As an aside, I want to clarify that I'm not advocating being a bad team player. The point to assigning blame isn't demonizing the developer of the faulty component, or reducing cooperation between developers of different components to the bare minimum. The point is just reducing the cost of fixing the problem.
- kazinator 11y agoAssignment of blame is important, but it is often an opinion. If one program misuses another, usually the fix can be an alteration in either one or both. The used program can be expanded to accept the "misuse" which is actually legitimate but not in the requirements. Or the using program can be altered not to generate the misuse. Sometimes what is fixed is chosen for non-technical reasons, like: the best place to fix it it is in such and such code, but ... it's too widely used to touch / not controlled by our group and we need a fix now / closed source and not getting fixed by the vendor {until next year|EVER} / ...
- lmm 11y agoMaybe cosmic rays give you a lower bound on the defect rate (though you can certainly measure and account for them). But I have never seen a complete system in which cosmic ray errors were anything more than the tiniest of undetectable noise, drowned out by the vast weight of software errors.