adventure with PVS-Studio C/C++ analyzer

I've recently read a promo article about a static C/C++ analyzer called PVS-Studio by, where the readers were urged to use the product, and I did just that. Evgeniy Ryzhkov, the creator of the program kindly sent me a one-week key, and I immediately started testing some of my C/XS code.

I'm also using valgrind and was rather sure that all major problems were long gone, but how wrong I was. There were also a couple nasties, in cases not covered by tests, and thus valgrind had no chance to detect them. There were also a couple of WTFs, such as

void * x = result();
x-> something++;
if (!x) return;

where the logic was clearly there, but somehow on wrong lines. A shame really.

I did like the output of the analyzer, and not content with that, tried to run it against the latest perl sources. Retroactively, an idea struck me, that there's little chance that I'm the first person trying to do that, but google only gave me a last-year mail from Jarkko Hientaniemi where he asked the p5-porters if anyone could do this. Feeling like a necromancer (i.e. the one who loves reviving dead threads) I produces this: . It's mostly noise, but there are a interesting remarks as well, for example:

Uninitialized variable 'len' was used. The variable was used to initialize itself.
CvOUTSIDE(PL_compcv) = MUTABLE_CV(SvREFCNT_inc_simple(outsidecv));

...and good luck figuring out where there is this _p and whether it was indeed uninitialzied or it was false alarm.

I also tried to run it against a couple larger perl distros (same directory online), but it's much less interesting.

All in all I think PVS is a decent tool in the box (John Carmark of Doom's fame apparently loves it), it runs on both linux and win32, but for the price of over $5k it not something one decides to use easily. On the downside there were lots of noise errors, that are not errors at all, it took really long time to munch on a 200K+ C file from rakudo, so the way the company advocates to use the tool, as a part of build process, might not always be practical.

If you're interested to run your pet C project through it, I've read on the company site that open-source tools might be given a short evaluation key without support for exactly that purpose. However there's one thing that I couldn't stop thinking about. Statical text analyzers like this should've been written in perl, should've been a perl killer app, but somehow ... they haven't. I wonder why.

playing with Cairo

I was recently reading a brilliant post A first-person engine in 265 lines by Hunter Loftis, and instantly wanted to port it to Perl. After doing half of work, though, I figured out that the original code uses alpha blending technique to achieve wall shading, rain, and drawing images with 8-bit transparency channel.

I've used Prima to write the port, even though it doesn't support alpha channel, because native x11 API doesn't do that. Goog…

how I learned to plot a mandelbrot set

When I first met fractals in the school, I thought that they were if not magic, then something very close to it. The concept of a fractal dimension was something I couldn't react to logically, but only emotionally, basically, with a "wow" and nothing much else. I never tried though to write a program that plots the set, even though there plenty of examples around; a deity isn't there to be analyzed, only to be awed at.

Enter year 2013, and I find myself reading PDL mailing list where someone has post…

twinkle twinkle catalyst

I'm developing under Catalyst and am using the Catalyst test server that is running on my local machine and is reloading every time I'm saving changes to the source tree. This is a cool feature, but I have to wait in front of the browser until the application is loaded full and can answer http requests; if I hit F5 in the browser before it is up and running I get a connection refused error and have to hit it again.

Finally I got tired of that and wrote this little hack that shows a load indicator on my ubuntu desktop. Th…

Re: Asynchronous HTTP Requests in Perl Using Whatever

In addition to asynchronicity I couldn't stop and wrote this:      has length      216 and loaded in 0.048 ms   has length     4648 and loaded in 0.341 ms    has length    31651 and loaded in 0.147 ms    has length     2966 and loaded in 0.172 ms   has length    83905 and loaded in …