3 ms·
I have a naive question here. Could this have been avoided if they had used Rust? Or is this a bug that can happen even in Rust code too?
by vijaybritto 2y ago
I have a naive question here.
Could this have been avoided if they had used Rust? Or is this a bug that can happen even in Rust code too?
- surajrmal 2y agoIt can be avoided in any compiled language that has a boolean type. That includes C these days. Unfortunately this functionality predates the existence of the boolean type.
- probably_wrong 2y agoThe original bug was returning STATUS_SUCCESS to indicate that a function had succeeded without noticing that STATUS_SUCCESS is defined as 0 in a function that's expected to return a non-zero value on success. This specific error could have happened on any language - defining two different return types and using the wrong one could happen in any language.
- andy12_ 2y ago> defining two different return types and using the wrong one could happen in any language This specifically is the kind of bug that is avoided with strong typing. The compiler screams at you when using the wrong return type. For example, if a callback expects a Result type, you must return a Result type, not some random int-like value whose definition of success and failure is arbitrary.