Mountain Biking Helps Squash Bugs 82
Dr.Milius writes "Henning Brauer of the OpenBSD project recently made an interesting post to the openbsd-tech mailing list about how a mountain bike ride helped him relate two baffling bugs in their new BGP and NTP daemons. It turns out they were both off-by-one errors that were easy to fix but notoriously difficult to spot. Always great when the experts show us how it's done."
RTFB (Score:5, Funny)
Re:really stupid (Score:2, Funny)
Re:really stupid (Score:2, Insightful)
works for anything (Score:3, Insightful)
Re:works for anything (Score:2)
Ditto.
This is news?
EVERY half-decent dev or tech has these kinds of down-time epiphanies.
(For me, it's the shower and commuting.)
Re:works for anything (Score:1)
road bike.. (Score:5, Funny)
Re:road bike.. (Score:1)
This is news? (Score:5, Informative)
I, for example, will often go grab a Coke, talk to people, etc, and somewhere along the line, by _not_ focussing so hard on the problem, I come up with the answer.
Re:This is news? (Score:1, Flamebait)
Re:This is news? (Score:1, Flamebait)
Re:This is news? (Score:4, Insightful)
Re:This is news? (Score:1)
Re:This is news? (Score:2)
Re:This is news? (Score:5, Funny)
It's not the bike riding, it's the act of "taking a break from the problem."
I'll second that. I do some of my best coding in the bathtub, sans the dangerous electronics, of course.
not difficult to spot at all (Score:5, Insightful)
Face it, memory corruption bugs, off-by-one-errors, and all that, happen to even the most experienced and careful programmers. The way to deal with them is to use programming languages that detect them reliably. In different words, we need to retire C or fix C.
And, no, "retiring C" doesn't mean switching to Java or C#. Instead, it means switching to a systems programming language that has error checking by default but still gives you all the low-level features you need when you need them. There have been a number of such languages over the years, but, unfortunately, they were all killed by C, not because C was better, but because C shipped with UNIX.
Re:not difficult to spot at all (Score:5, Informative)
As for not using C, I've read that Theo de Raadt likes the compiler and language that is used in Plan 9 [bell-labs.com]. Can't use it due to license problems, though.
Re:not difficult to spot at all (Score:1)
You mean Alef? I don't think there are licensing problems with the language, and writing a compiler for it wouldn't be hard. I'm not convinced, though, that Alef is a good systems programming language.
But safer systems programming languages are a dime a dozen, people just have to use them.
Re:not difficult to spot at all (Score:4, Informative)
Re:not difficult to spot at all (Score:2, Interesting)
Re:not difficult to spot at all (Score:3, Informative)
There are debugging tools out there which reliably find these bugs in C/C++ and FORTRAN. For example:
purify (not free)
valgrind (free)
Tools such as these help to find problems, while avoiding the inefficiency of array bounds checking on each acce
Re:not difficult to spot at all (Score:5, Insightful)
How is bounds checking inefficient if it protects you from nasty off-by-one errors and evil buffer overflows? Or are you one of those short-sighted programmers who believes cheap CPU clock time is more important than very expensive human time (i.e. time wasted dealing with crappy programming languages and debugging stupid bounds problems, or worse, money lost because a critical bit of information was destroyed, altered, or disclosed due to a buffer overflow vulnerability)?
And yes, those were both rhetorical questions. I am sick and tired of crappy, bug-ridden software that doesn't do proper input and bounds checking. As far as I'm concerned, it's the programmers fault, either because she didn't write the bounds checks in manually or because he's not using a modern programming language (where "modern" == "not a glorified assembler"). You all aren't Mel, who can write practically perfect programs while sleepwalking, so don't give me a load of crap about how bloated your program would be if it was actually written properly. As a computer security guy, I am sick and tired of cleaning up after the exploits you all apparently work so hard to code into your software.
</rant>
Re:not difficult to spot at all (Score:1)
Re:not difficult to spot at all (Score:2, Informative)
No debugging tools there, if any tools at all.
Re:not difficult to spot at all (Score:4, Insightful)
Re:not difficult to spot at all (Score:2, Informative)
Re:not difficult to spot at all (Score:1)
This is only because the C runtime does not help in this regard. This can be done very efficiently in other environments.
Re:not difficult to spot at all (Score:1)
No, they don't find them "reliably", they only find them if you happen to have a test case that triggers the bug and you run the software under valgrind or purify when you execute the test case. For security problems arising from buffer overflows, the probably is usually that developers don't even think of the case.
Tools such as these help to find problems, while avoiding the inefficiency of array bounds checking on
Re:not difficult to spot at all (Score:2)
Nevertheless, it would probably be a big step forward if Linux and BSD allowed C++ code in the kernel.
Re:not difficult to spot at all (Score:2, Informative)
Re:not difficult to spot at all (Score:1)
I'd certainly welcome any ideas people have on how they actually debug code using the STL.
Re:not difficult to spot at all (Score:4, Insightful)
yeah, garbage collection would help, but C with GC is not a "systems programming language with error checking".
Re:not difficult to spot at all (Score:1)
A systems programming language with error checking needs to handle both automatic storage management and array bounds checking (plus a few other compile-time and runtime tests that are missing from C). Users should also be able to turn off either/both selectively and explicitly.
Re:not difficult to spot at all (Score:1)
I don't think you understand the "low-level" appeal of C, error checking and other useful security features like strong typing are not low-level. The ability to break abstractio
Re:not difficult to spot at all (Score:1)
The best check for such errors is other eyeballs.
It's not the language. It's development procedures. Code reviews will catch these things, and other bugs besides (as well as making people write neater, more easily understandable code, and giving coders and opportunity to learn from each other), but reviews take development time - never mind all the time they save in deb
bounds checking gcc... (Score:2)
use it [nl.net].
Not new... (Score:3, Insightful)
It happened to each of us, no need to be an expert or something: the bug drives you nuts, and you end up saying "fsck that" and go out, totally out of ideas. Then you smoke your cigarette of whatever, or go for a walk. And because you've sort of given up, you start to look at the problem in a different way, probably also because you're not in front of your screen and your brain is more "free", you realize that there are some obvious things that you didn't checked... And 5 minuts later, there is no more bug. That's why i go out to smoke a cig every hour (well not really, but still, it's a nice excuse
Besides, if you look at the well known "eureka" moments, it seems they all happened when the person was relaxing. Maybe we should be forced to relax each time we're facing an intellectual difficulty, really...
Re:Not new... (Score:1)
If it's the second half of the afternoon,
I just go back home.
During the evening,
Off for a beer.
Any other moment,
Walk, coffee or walk to coffee...
And yes, it does work. I usually find my bugs within 10 minutes after sitting back to my desk, which obviously includes reading slashdot.
Re:Not new... (Score:1)
Re:Not new... (Score:2)
Re:Not new... (Score:2, Funny)
Re:Not new... (Score:1)
Re:Not new... (Score:2)
Re:Not new... (Score:2)
I'm now trying to restrain myself from doing this, as sometimes you can furthermore do stupid things which will cause you to spend even more time later on, solving problems which should hav
Bake Cookies! (Score:4, Interesting)
Re:Bake Cookies! (Score:2)
taking a crap (Score:5, Funny)
Re:taking a crap (Score:4, Funny)
*yawn* (Score:2, Insightful)
Would a more modern language madea difference? (Score:2)
I was wondering if this is the kind of thing that most likely would ahve been avoided in a more "modern" language, like pointer arithmetic problems could be avoided by not using C? Not a trool -really- I was just wondering. I RTFA but can't tell from reading it...
Re:Would a more modern language madea difference? (Score:1, Insightful)
Re:Would a more modern language madea difference? (Score:1, Insightful)
Someone who believes this can be done has to prove it by reimplementing an existing OS in one of these "modern languages", and demonstrate that it is maintainable, performs sufficiently, and actually works better than a C implemented OS. Implementing a "whole new" OS isn'
Re:Would a more modern language madea difference? (Score:2)
Re:Would a more modern language madea difference? (Score:2)
This is important because the programmer has some idea of what the program is actaully doing, and a good programmer has a great idea of what the program is actually doing.
Anything that is pretty close to the hardware should be done in C or soemthing similar. Computers have been f
hard-to-find bugs are often the easiest to fix (Score:3, Interesting)
I often find that the bugs that are most difficult to find are the easiest to fix. They are often some tiny corner case in one line of code that someone never thought of.
In the last product I worked on, we had a killer crash bug that different developers spent WEEKS investigating it, giving up, and then "hot potatoing" the bug to another developer. About two months later, I finally fixed the bug. A BSTR allocated using SysAllocString() should have been freed using SysFreeString(), but it was being "freed" using COM's CoTaskMemFree(). This would corrupt COM's heap causing random COM crashes in unrelated code much later!
Re:hard-to-find bugs are often the easiest to fix (Score:3, Interesting)
Re:hard-to-find bugs are often the easiest to fix (Score:1)
http://msdn.microsoft.com/library/default.asp?url
Re:hard-to-find bugs are often the easiest to fix (Score:2)
Only in debug mode, of course.
I've never understood this philosophy. Let's put lots of error checks and consistency checks into the system, then rip them all out when we ship the software or transfer it to operations.
If it doesn't have to be correct, we can make it run as fast as you like.
Valgrind and/or GCC boundschecking (Score:1)
Yes! (Score:3, Informative)
Yes! This can make tweaking your overall algorithm or approach so much easier as well, if these wrapper functions are there, and well defined in their actions. You can never have *too short* a function!
Just taking a break is helpful, but ... (Score:2)
Hummm.... (Score:3, Funny)
Off by one error (Score:1)