4 ms·
Yeah, but the fact is that there are billions of lines of C out there, and tens of millions more being added every year, and that's not going to change for a wh
by pron 10y ago
Yeah, but the fact is that there are billions of lines of C out there, and tens of millions more being added every year, and that's not going to change for a while. Under no scenario will more than, say, 50% of new systems code be written in a memory safe language within the next 15 years. It doesn't matter what we want or what we think the industry should do; given the rate of change in those sections of the industry that use C/C++, realistically that's just not going to happen any time soon, while the errors already affect us.
That doesn't mean people shouldn't switch to safe languages for new projects if they can, but it does mean that they should use the tooling available for C much more. Unlike what the article claims, they don't -- at least not those who write programs with lots of memory safety issues. There are static analyzers that can guarantee -- 100% -- no memory safety issues. Airtight guarantees may take some work, but it's still far, far cheaper to achieve using state-of-the-art tools than switching to a new language for many projects (even new ones in organizations where C is established, let alone old ones). Unlike what the article claims, programmers utilizing state-of-the-art C tooling and best practices do not "constantly produce programs riddled with severe memory safety vulnerabilities".
Unfortunately, those state-of-the-art tools and practices are used almost exclusively by authors of safety-critical software, and are not commonly used in more mundane kinds, let alone in open-source projects. An intervention more likely to work in the short term should push for that, regardless of longer-term solutions in the form of safe languages.
- zzzcpan 10y agoTooling requires a lot of effort from every programmer too, it cannot work on the scale you are talking about. On that scale compatible memory-safe C compiler or transpiller are pretty much the only options, since gcc and llvm don't care about that.
- pron 10y agoI don't think we can guarantee the absence of that kind of errors from all existing billions of lines, but the work is still far cheaper than switching languages. New projects can make use of sound static analysis from the get-go, and old projects can apply them incrementally.
- zzzcpan 10y agoAnything we can't guarantee statically we can check at runtime, which is what memory-safe C compilers do. But this is something OS distributions can use on all of the C packages. What you are suggesting is an effort that each and every project has to take and this simply doesn't scale much better than switching languages.
- pron 10y agoI do think that sound static analysis tools are far cheaper than adopting a new language, and they can be used incrementally (i.e., lesser guarantees are cheaper), but sure, memory-safe C compilers, too! (I'm just not familiar with the approach; links?) My point is that there are solutions that we can start applying today short of rewriting in new languages, or at least until we rewrite.
- zzzcpan 10y agohttps://www.cs.rutgers.edu/~santosh.nagarakatte/softbound/ https://www.cs.rutgers.edu/~santosh.nagarakatte/softbound/ http://sva.cs.illinois.edu/index.html http://sva.cs.illinois.edu/index.html http://chrisseaton.com/plas15/safec.pdf http://chrisseaton.com/plas15/safec.pdf
- pron 10y agoLooks interesting and I see that some of the solutions use static analysis, too, but your links are all academic projects. Are there any production quality memory-safe compilers yet?
- fauigerzigerk 10y ago>I do think that sound static analysis tools are far cheaper than adopting a new language For new projects I don't really see why that should always be the case. It probably depends on the type of project, on the organization, on any integration requirements and on the willingness of developers to make the change.
- deleted 10y ago[deleted]
- lawnchair_larry 10y ago"There are static analyzers that can guarantee -- 100% -- no memory safety issues." This is untrue, at least for any practical interpretation of such a guarantee. Which product do you think does this? Note that for it to count, it has to return the results before the programmer is dead.
- pron 10y agohttps://trust-in-soft.com/products/ https://trust-in-soft.com/products/ (a commercial product from the people who've built Frama-C) Sound static analyzers are not 100% automatic. They require user help in the form of annotations in cases where they can't prove everything automatically. But the work required is similar -- probably less -- than writing tests. Also, note that it's very easy to find all memory safety errors in a sound way -- you just report every pointer and array access that's unsafe. The problem isn't identifying all errors, but proving the memory safety of the cases that aren't (and that's where they may ask for help in the form of annotation -- to convince them of the absence of an error).
- lawnchair_larry 10y ago"They require user help in the form of annotations in cases where they can't prove everything automatically." So, like I said then. Doesn't exist in any practical form :) Annotations are clearly a non-starter.
- pron 10y agoRight, because clearly adding some annotations (which is similar in effort to writing test cases) is a non-starter while rewriting hundreds of millions of lines of code in new, immature languages is going to solve the problem faster. And that nonexistent-in-practice approach is commonly used in safety critical software.
- lawnchair_larry 10y agoMark my words. In 10 years, there will be no more adoption of annotations than there is today. If you can't get anybody to use something, it's a non-starter. It doesn't matter why. It just hasn't happened and it wont happen.