3 ms·
> I am a C programmer, and to me buffer over-runs are a rare class of bugs, and a class of bugs that are (at least on the heap, and often on the stack) trivial
by anchpop 6y ago
> I am a C programmer, and to me buffer over-runs are a rare class of bugs, and a class of bugs that are (at least on the heap, and often on the stack) trivial to find and fix with the tools i have.
What does your testing setup look like? Does it include regular fuzzing and security audits? Buffer overruns are so common because normally your mental model of how the code should work assumes they don't happen, so you forget to test for their presence (or prove their absence, like Rust nudges you to).
- quelsolaar 6y agoI tend to have tests on a lot of the time (see below about my test lib). As someone who has worked with C for a long time, I think my mental model is all about direct memory access, so it probably comes more natural to me.
- megous 6y agoThat sounds like the opposite of the mindset I have when writing C. Keeping buffer limits in mind all the time, and having them communicated around the code/function calls and respected, is one of the most basic things. I don't do fuzzing, because I leave string parsing to tools like re2c. I tried it in the past with my mail message parser written in C/re2c and it was not very helpful.
- benibela 6y agoThere are also other low-level languages besides C and Rust I use Pascal, and I never have any buffer overruns in my code. If there were any, Pascal's automatic bound checking on array indices would raise an exception The only issue is, should I keep the bound checking in the release builds for maximum safety, or disable them for maximum performance?