Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: Evaluation - 05.12

>
>
>
Use of uninitialized memory

Use of uninitialized memory

Mar 12 2013

The use of uninitialized memory is one of the most common errors in languages with manual memory management. The purpose of this process is to read data from an allocated buffer that hasn't yet been filled with initial values. The program behavior is a bug that is sometimes difficult to detect. This is the so-called "Heisenbug". Whether it appears or not depends on the version of the compiler or OS we're using, and whether we're running a "debug" or "release" build.

Most often, the error occurs due to an incorrect initialization order or synchronization error in a multithreaded application. Nevertheless, the data is used before it is initialized.

Let's take a look at such an example:

dgCollisionCompoundBreakable::dgCollisionCompoundBreakable(....)
{
  ....
  dgInt32 faceOffsetHitogram[256];
  dgSubMesh* mainSegmenst[256];
  ....
  memset(faceOffsetHitogram, 0, sizeof(faceOffsetHitogram));
  memset(mainSegmenst, 0, sizeof(faceOffsetHitogram));
  ....
}

The error occurs because of the incomplete initialization of the mainSegments array. In the second call of the memset function, someone made a mistake in the third argument and passed the size of the faceOffsetHitogram array. The code will properly function only when it compiles on a 32-bit platform, where the pointer size matches the size of the dgInt32 type. The program won't operate properly when it compiles on a 64-bit platform.

References

Popular related articles


Comments (0)

Next comments next comments
close comment form