A Summer Spent on the LLVM Clang Static Analyzer for the Linux Kernel
As a kid, and some ten years before he started using Linux, Eduard Bachmakov dreamed of one day being involved in open source software. He didn't really know how code worked, but thought the idea of collaborative global development, free of corporate interests, was cool. He started by playing around with virtual machines and dual boot, but didn't make the full switch to Linux until he got to college, he said.
Now a dual-degree major in computer engineering, astrophysics and astronomy in his senior year at Villanova University in Pennsylvania, Bachmakov is doing some real programming. And this past summer, through his Google Summer of Code internship with The Linux Foundation, he worked on Linux for the first time.
Bachmakov contributed to the LLVM Clang Static Analyzer for the Linux kernel with LLVM project lead Behan Webster and Linux Foundation trainer Jan-Simon Moeller as one of 15 GSoC interns with the Linux Foundation this summer. The analzyer is a userspace tool used at compile time to find bugs in a patch before it's submitted, Bachmakov said. It was an appealing project to him, not only from a technical perspective but because it could have an impact on a larger group of people as support for the Clang compiler for the kernel grows, he said.
“People have heard about it, and some are using it a little bit, but no one is even close to using it near its full potential,” Bachmakov said. “So ideally if this tool for development would be developed further, a lot of sleepless nights would no longer occur.”
Say, for example, you're allocating memory and for whatever reason end up freeing it twice, Bachmakov says. “A compiler can’t find that, but through a static analyzer you can write a checker that keeps track of where you’ve allocated memory and find paths through your program to find where you’d done it twice.”
Much work toward creating a static analyzer for the Linux kernel had already been done as part of the LLVM project. One of the goals of Bachmakov's internship was to demonstrate how the analzyer works through a tool that traces where errors come from and creates a report. (See an example of his checker tool, here.) He also set out to make a selection of checkers that make sense within the kernel.
“A lot (of checks) while technically correct, don’t apply. Many checks are just omitted because it’s understood that this would never happen,” Bachmakov said. “These are issues that can’t be read from the code. These are things you have to know, so there were a lot of false positives.”
While his main concern now is prepping job and graduate school applications, Bachmakov says he'll continue to contribute to open source projects. He's playing around with a small Snapdragon development board to see if he can build a kernel for it and compile it with Clang.
He doesn't quite feel ready to be a kernel developer, he says, but “whatever my job ends up being I’ll try to incorporate as much Linux and open source as I possibly can.”
Editor’s note: Stay tuned in coming weeks for our series of profiles on Linux Foundation GSoC interns. If you’re interested in learning more about Google Summer of Code internships in 2014 please visit: http://www.google-melange.com/gsoc/homepage/google/gsoc2014
The next round of applications starts Feb. 3, 2014.