4 ms·
Frama-C is a suite of tools dedicated to the analysis of software written in C
- rhth54656 13y agoThe only option for windows is manual compilation using a POSIX library. Any suggestions for a similar tool?
- emmelaich 13y agoHere's a list. http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis#C.2FC.2B.2B http://en.wikipedia.org/wiki/List_of_tools_for_static_code_a... but sorry no suggestions or recommendations.
- conductor 13y agoCppcheck - http://cppcheck.sourceforge.net/ http://cppcheck.sourceforge.net/
- rhth54656 13y agoThanks, I just tried it and it found an assignment in an assertion that the compiler didn't warn because it wasn't an if statement. I ran it over a couple of old finished projects and it found a problem in each one. Awesome. Unfortunately it misses a class of errors memcpy would do,( similar to heartbleed ) , if copy size is determined at runtime.
- rurban 13y agoKlee, EXE, Forensic, cbmc, BAP all mix symbolic analysis with SAT solvers into the C parse tree, and can come up with input to contradict the assertions. (automatic testcases or exploits) Frama-C still beats all with it's interface, but Forensic is so nice that it even tells how the fix should look like. https://en.wikipedia.org/wiki/Model_checking https://en.wikipedia.org/wiki/Model_checking
- glifchits 13y agoWhat would this say on the OpenSSL code that had the Heartbleed bug? (Edit) this: https://news.ycombinator.com/item?id=7571506 https://news.ycombinator.com/item?id=7571506
- rurban 13y agoFrama-C does not say much, when do don't tell it what it should do. It needs to reason over symbolic facts, C code is not enough. It's not just another simple static code checker. You can look at the Frama-C blog what it does with a major openssl competitor, polarssl. http://blog.frama-c.com/ http://blog.frama-c.com/
- xvilka 13y agoIt is very handy - http://xvilka.me/frama-c.png http://xvilka.me/frama-c.png - screenshot of the integer overflow found.
- z3phyr 13y agoI really like your config :)
- TorKlingberg 13y agoIt would be good to hear other HN:ers experience with various static analysis tools for C. I have had good experiences with Flexelint (PC-Lint). It does not attempt to deeply analyze control flow, more like compiler additional warnings. It flags a lot of common mistakes and can basically turn C into a more strictly typed language. I feel a lot more confident in C code if I know that it passes lint, since it warns if you try to mix unsigned and signed ints, cast away const, call functions with wrong types etc. Like many static analyzers it takes some work to set it up, and tune which warnings you actually car about. It is definitely business-priced and feel a bit old (although command line tools age well. The is a clear lack of good open source tools. I tried all i could find, but Splint was the only one that would flag switch-cases without break. It was last updated in 2010.
- nullc 13y agoI like Frama-C a lot in theory, though in practice I found it hard to use except on very small code segments. When its unable to prove a range the feedback you get from the solvers is inscrutable enough that its very hard to figure out what additional data it would need to satisfy the analysis. (Sort of like parsing C++ compiler template related errors) I'd hoped that language features like the typestate stuff that used to be in Rust would someday make the work required to use sound analysis tools in production code smaller. I'm not sure if much thought has been given to what kinds of accommodations languages could give to ease static analysis while still being programmer friendly. It seems that newer languages have actually moved away from analysis friendliness in some respects, however. E.g. in C a signed overflow is always a bug so if analysis can prove one is possible you have something to fix. Several modern languages have defined signed operations to wrap and so that obvious safety test is no longer available. (You could define in your own code that it should never wrap, effectively writing in a subset of the language, but as soon as you call into third party code you never know if an overflow was intended and safe or not— not without extensive analysis)
- pcwalton 13y ago> I'd hoped that language features like the typestate stuff that used to be in Rust would someday make the work required to use sound analysis tools in production code smaller. I'm not sure if much thought has been given to what kinds of accommodations languages could give to ease static analysis while still being programmer friendly. Well, since the Rust borrow check is basically a static analysis that's always on and is required to pass for the compiler to emit code, we've put a lot of thought into how to make it as programmer friendly as possible. The final trick that seemed to got it to fall into place was restricting data to only one mutable reference at all times—this was a restriction that's easy enough to understand and can be readily explained through error messages and tutorials. There's still a learning curve, of course, but I think we've got the system down to a reasonable level.
- detrino 13y agoI played with Rust for a day and while I was impressed with the language as a whole, I felt the borrow checker left a lot to be desired. I don't think having lifetime of references tied to scope works well in general. This is most evident in pattern matching where you are forced to grab your reference in the pattern (even if you don't need to use the reference until much further on), and there is no way to release it until the end of the scope (even though it can be dead much sooner).
- eliteraspberrie 13y agoOne feature you can start using right now: prove an assertion with the WP plugin. [1] It's especially useful to prove the absence of some undefined behaviour, bounds on variables, or invariance conditions. [1] http://frama-c.com/wp.html http://frama-c.com/wp.html