Explanations of common outliers in memory (such as 0XCCCCCCCC, 0XCDCDCDCD, and 0xfeeefeee outliers)

Source: Internet
Author: User

* 0xcccccccc:used by Microsoft ' s C + + debugging Runtime library to mark Uninitialised stack memory

* 0xcdcdcdcd:used by Microsoft ' s C + + debugging Runtime library to mark Uninitialised heap memory

* 0xfeeefeee:used by Microsoft's HeapFree () to mark freed heap memory

* 0xabababab:used by Microsoft's HeapAlloc () to mark "No Man's Land" guard bytes after allocated heap memory

* 0xabadcafe:a startup to the "value to initialize all" memory to catch errant pointers

* 0xbaadf00d:used by Microsoft's LocalAlloc (lmem_fixed) to mark uninitialised allocated heap memory

* 0xbadcab1e:error Code returned to the Microsoft EVC debugger when connection are severed to the debugger

* 0xbeefcace:used by Microsoft. NET as a magic number in resource files

Usually we only need to understand the above three common types can be: 0XCCCCCCCC, 0XCDCDCDCD and 0xfeeefeee, to help us quickly identify problems and analyze problems.

for 0XCCCCCCCC and 0XCDCDCDCD, in Debug mode, VC will not initialize the stack memory pointers are all filled with 0XCCCCCCCC, when the string to see is "Hot hot iron ..."; The uninitialized heap memory pointers are filled 0XCDCDCDCD, when the string look is "Tuen Tun Tun Tun ...". So why does the debugger do this? VC Debug version will automatically initialize the uninitialized pointer to 0XCCCCCCCC or 0XCDCDCDCD, rather than let random values, that is to facilitate our debugging program, if the wild pointer initial value is not deterministic, then each time debugging the same program may appear different results, For example, this time the program is broken, the next time it will be able to run normally, so it is obviously bad for us to solve the bug, so the purpose of the automatic initialization is to let us know at a glance that we have used the uninitialized wild pointer.

for 0xfeeefeee, it is used to mark the memory that has been freed on the heap. Note that if the memory that the pointer points to is freed, the address of the variable variable itself is not changed, or the address of the memory pointed to previously. If the pointer is a pointer to a class, and the class contains a pointer variable, the pointer variable in the class is assigned a value of 0xfeeefeee after the memory is freed (typically, the delete operation is performed for C + + classes). If you find a pointer with a value of 0xfeeefeee in the early debugging code, it means that the corresponding memory has been released and our code has gone wrong.

On initialization of variables in VC debug and Release mode

As you know, Debug and release do different things when initializing variables, debug is to assign each byte bit to 0XCC, and the assignment of release is approximate to random (I want to be allocated directly from memory, not initialized). This makes it clear that if a variable in your program is referenced without being initialized, there is a good chance of an exception: the use of a control variable will result in a process-oriented inconsistency, and being used as an array subscript will cause the program to crash, and more likely to cause inaccuracies in other variables to cause other errors. Therefore, it is the simplest and most effective way to initialize a default value immediately after declaring a variable, otherwise you will find no place to find it. Code errors in the debug mode may be ignored without being detected, such as the debug mode of the array out of bounds also most can not error, in the release is exposed, this find is more difficult (see: http://bbs.csdn.net/topics/350212712)

Explanations of common outliers in memory (such as 0XCCCCCCCC, 0XCDCDCDCD, and 0xfeeefeee outliers)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.