Comment by andai
15 days ago
SQLite: 92 million lines of tests
Dijkstra: Tests can only prove the presence of bugs, never their absence!
15 days ago
SQLite: 92 million lines of tests
Dijkstra: Tests can only prove the presence of bugs, never their absence!
Everyone knows that tests don't prevent all bugs. But they are very good at preventing known bugs from recurring in the future.
Everyone doesn’t seem to know that, because tests are often cited as a way to ensure that AI-generated code is correct.
I was very excited about formal proofs, which are now very cheap to produce, in service of validating AI generated code.
But I had a funny experience recently where an agent implemented an entire feature completely wrong (exactly backwards, actually, in a way that defeated the purpose, introduced security issues etc.).
It happily supplied tests for the new functionality, and all the tests passed.
What I realized was, even formal verification wouldn't have helped here -- it would have just written a mathematical proof that the incorrect functionality was correctly implemented!
So there's a gap here, where first, the human's intention needs to be formally specified (by the human, or at least the human needs to be able and willing to verify it), and then the slopswarm can hack away at it...
2 replies →
Donald Knuth: Beware of bugs in the above code; I have only proved it correct, not tried it.
The perfect yang to Dijkstra's yin
I admit to curiosity as to whether static analysis could have caught this. E.g., Rust's type system (yeah yeah I know) catches all data races, unless they originate in unsafe code, which this one might or might not have; a hypothetical Rust SQLite would probably need a lot of unsafe (https://github.com/tursodatabase/turso has 556 unsafe blocks in the core), and I don't have a sense of whether the particular part that contained this bug would be included in that.
There was a post recently using TLA to model this issue and (re)discover the bug: https://news.ycombinator.com/item?id=48730953.
Interesting. I don't think this kind of technique could realistically have caught the bug in advance, though; you're not going to model the entire codebase in TLA+, so the investigation in that post modeled just the parts that turned out in hindsight to be relevant.
3 replies →
I don't think they could. This is probably a memory-mapped file, which would be unsafe.
It sounds like it was a bug caused by pushing on performance/safety ratio, it could easily have been avoided by adding enough mutexes in the code, but for performance reasons (I assume) they don't do that. To write it like that in Rust you'd have to use unsafe blocks and then you don't gain much from the typesystem in this case.
I wouldn't think so, but Go also has a data race detector: https://go.dev/doc/articles/race_detector.
That's dynamic, not static; it doesn't help much with a race that's hard to trigger.
>Rust's type system (yeah yeah I know)
What do you know?
Presumably he is referring to rust fanboys' tiresome criticisms of everything C.
It can prove absence of specific bugs though.
no it can't. what if this bug is still there but the timing window is now one CPU instruction?
> what if this bug is still there but the timing window is now one CPU instruction?
I think a model checker or something similar that can exhaustively cover a search space would suffice, though at that point I think the boundary between "test" and "formal verification" becomes somewhat fuzzy.
8 replies →
Then it’s a different bug: they fixed a bug with a wider timing window and introduced a new bug with a narrower timing window.
You simply don't have enough testcases.
Testing:
The union of a lot of necessary conditions is not a sufficient condition. But it might be good enough for software.
The idea of testing is to sample and test the paths you care about, mostly business workflows, not to enumerate infinite combinations.
It's an art to come up with a great test suite that covers just enough and minimizes overlap, not only survives but also helps with refactoring.
probatio diabolica
https://en.wikipedia.org/wiki/Probatio_diabolica
https://07th-expansion.fandom.com/wiki/Devil%27s_Proof
https://news.ycombinator.com/item?id=18442941
Jesus Christ. I have this comment saved, but it gets me every time.
Obligatory UNIX fortune: "Computer Science can be thought of as the post-Turing decline in formal methods."