No votes yet.
Please wait...

There is nothing worse than an error that comes from nowhere and does not correspond to any code execution path. If you find yourself in this situation, it is most likely due to writing to uninitialized memory, also known as writing to a random address (wild write). The reason for such errors lies in the uninitialized pointer, which by chance indicates a correct memory area. This usually happens with stack pointers or, otherwise stated, with local variables. As the stack constantly changes when you execute your program, nothing can tell you where the uninitialized pointer points, which is why it may seem random.


When debuggers are asked to help to resolve this insidious problem, they always deal with completely confused programmers who claim to have tried literally all the ways to identify it. Since they have already done “everything”, they desperately want to know what the debuggers will conjure. They respond by saying they are about to apply the patented and registered Magic Way of Debugging Uninitialized Memory by the Ninja Technique (MNUMDT). Everyone is going to look at this and shift in armchairs, waiting for a miracle, especially when the debugger mentions that MNUMDT will work only if two of the least experienced developers of the group help him.


Website testing service is available to ensure that e-commerce site works as intended. This is used to check content of a webpage to make sure that it is quite appealing to the visitors.


At that moment, two junior programmers are approaching the debugging person, showing in every way that they intend to carry their burden with dignity, and the debugger is describing MNUMDT to them:


  • each of us is assigned to work with one third of the code;
  • everyone should carefully read each line of code, looking for all the declarations of pointers;
  • if we find an uninitialized pointer declaration, we initialize it with the value NULL;
  • when every memory allocation call is detected, not for classes, after it we add a memset or ZeroMemory call to zero the memory;
  • after any memory is freed, we again assign a zero value to the pointer;
  • when finding a memset call or a line copy operation, we need to check that each operation correctly counts the size of the memory block;
  • each variable of the class member must be initialized in the constructor (s).


Listening to the MNUMDT rules, the guys are ready to run out of the room, but the leader does not let them do it. If you think this is gross violence, you are absolutely right: it is.


Comments are closed.