Sunday, September 18, 2016

Hidden Bugs... The Real Nighmare!!!!

Have you every had to fix a leaking flat roof?

A strange question to ask on programming blog. But there's mileage in this simile. You see, when a flat root shows signs of leaking, its on the inside of the building, where the water comes out, not where it goes in. In other words, you can see the effect, but not the cause. Moreover, the effects of a leaky roof are cumulative, not immediate.

I've just fixed an intermittent crash in the gnocl core module when complex dialog layouts holding multiple buttons are closed. There was nothing wrong with the C code or Tcl scripts, each were grammatically correct, but still the crashes occur with the typical segmentation error being reported.

This is indicative of the free() function attempting to release unused memory but the code uses g_free() which has some built in protection, i.e. it returns if the memory pointer is NULL.

The problem was resolved by commented out one of the g_free lines in the button.c module buttonDestroyFunc. It would suggest that something bizarre was happening in the compile process, perhaps some side-effect of optimization which had gone wrong.

Anyway, big relief this bug has been squashed, zapped, splattered! -GONE!!!