A week in the life of Mike…


I spent all of last week debugging a very weird problem with a colleague, where a small service (roughly 3000 lines of code) was appending a random set of characters at the end of a message, at seemingly random times. In hindsight we were surprised the code actually ran without crashing. But just to let you know that IT is not an entirely glamorous job (ie: it can be very tedious) the code looked like this (drastically changed to protect the innocent):

int doSomething(char **str) {
    //snip some lines
    str = xmlDoc->getRawBuffer();
    int len = xmlDoc->getLength();
    str[len] = '\0';
}

Where the last line should actually have read like this:

    (*str)[len] = '\0';

It looks innocent, but the incorrect version was overwriting memory somewhere. Unfortunately it took an entire week to figure that part out. Landscaping is looking very attractive.


Comments are closed.