Visual C + + Runtime features--non-scalding is the Tun

Source: Internet
Author: User
Tags vc runtime

Visual C + + Runtime features--non-scalding is the Tun

Freshman just learn C language, the second time on the machine class, when I found that I follow the book copy of the program in the black box outside the run jumped out of a row of "Hot Hot Hot Hot hot", then shocked. Can you imagine a child from a small town who had never been exposed to a computer or code before college? I really thought it was a warning that the computer was overheating, so I bent down and pulled the plug.
——————————————————————————————

VC Runtime Debug version will initialize the stack into 0xcc,unicode 0XCCCC (double byte) is the Chinese hot. If you open a char[], and then the last character is set to 0x00, and then go to the printf character, then the entire stack from this local character array start output to the console, it becomes a "Hot Hot Hot Hot hot."

Why did you initialize stack to 0XCC instead of 0x00? is because 0XCC in the Intel x86 chip instruction set represents int 3, that is, debug interrupt, the instruction will automatically stop the program in a single-step debugging state, and then to find the system registered debugger, if the debugger is not found, then the program will be terminated. This was started in order to debug the stack buffer overflow error. If an overflow occurs, and the code tries to execute the instruction in the buffer, it goes into a single-step debug state.

This is debug version, so what about release verion? The release will initialize the stack to 0xCD, this is IMM8, is immediately interrupt exit meaning. This is because it runs on the user's machine, does not have a debugger, and does not want users to debug your program. 0XCDCD is the word "tun" in Chinese. You will see some of the very bad writing programs often appear "Tun Tun Tun Tun Tun Tun". It's quite a tun, F.

In today's chip DEP, operating system NX locks the era of double insurance, this initialization is no longer necessary, the iron is still a purely historical reason.

So in our computer also compared to the old age, said people character is not good, it is called non-rape is stolen. Say that the program is bad, it is called non-hot tun.

Reference:
http://www.ccthere.com/article/4019197

Visual C + + Runtime features--non-scalding is the Tun

Related Article

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.