Use of uninitialized memory

Use of uninitialized memory means reading data from the buffer that was allocated but not filled with initial values. The program behavior in this case is considered an error which is quite difficult to detect sometimes. This is a so called "heisenbug". Whether or not the error reveals itself depends on the compiler version or operating system version as well as which program version, "debug" one or "release" one, you're running.

The error may occur because of an incorrect initialization order or race condition in a multi-threaded application. In any case, it means that the data are starting to be used before they are initialized.

Consider an example of this error:

  dgInt32 faceOffsetHitogram[256];
  dgSubMesh* mainSegmenst[256];
  memset(faceOffsetHitogram, 0, sizeof(faceOffsetHitogram));
  memset(mainSegmenst, 0, sizeof(faceOffsetHitogram));

The error is this: the 'mainSegmenst' array is initialized incompletely. This code will work correctly in the 32-bit program where the pointer size coincides with that of the 'int' type; but it will fail in the 64-bit program.


Bugs Found

Checked Projects
Collected Errors
14 526
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →