Runtime database and runtime check-software debugging notes

Source: Internet
Author: User

WriteCodeIt has been four years. In fact, I have made progress every day. Recently, I often see the technical director debugging, operating the computer, debugging bugs, and learning a lot. He was willing to take me with him. He ran to my computer to debug the problem several times. However, it is impossible for the experts to detail these skills in detail. They will only teach you a way of thinking and a way to let you go to Baidu, Google, and communicate with other masters, learn by yourself. Recently, there have indeed been many problems in product operation, basically making the server stable without stopping debugging. Now users are very harsh, and many overlord terms and servicesProgramIf you want to lose money, the boss is busy, and you are under a lot of pressure. Everything has to be stable. Recently, I have been engaged in windbg and I am very interested in this item. Of course, I am still very happy now. I feel that I have made progress and can promote the efficiency of the entire team, so that everyone can benefit from it.

The book software debugging was bought in March. After reading this book for a while, I felt I could not understand it. Now I can turn it back and try again. It's not that hard, because I understand it now, I am very excited in my mind that I can use my products right away. I am indeed a master, and I have benefited a lot from communicating with the master. This book has read a lot of chapters before, but also to facilitate memory and write down notes.

1. Epiphany

Run database and run-time check, this thing was previously exposed to this thing in vc6, knowing that sometimes the cstring or some memory is inexplicably released, it may be a problem with the runtime database, just let it go, however, I don't know why. Recently, when a colleague encountered this problem, I suddenly thought of it and suddenly understood what it was like. Maybe it was an epiphany and it felt amazing. Later, let's look at the text of instructor Zhang, and I have a more systematic understanding.

2. C/C ++ Runtime Library

When the compiler compiles a high-level language into a low-level language, some complex operators in the high-level language need to correspond to a large number of low-level language commands, to prevent such instruction segments from repeatedly appearing in the target code, the compiler typically encapsulates these instruction segments as functions and translates some operations in advanced languages into function calls. (For example, the new and delete operators are compiled to call the malloc and free functions)

So I have always hoped that new and delete must be c ++ memory processing, and its underlying layer may be encapsulated with malloc and free, so sometimes the memory applied for in the DLL, run to EXE to release, or on the contrary, this may lead to unexpected problems.

3. link the Runtime Library

The C-run DLL of the vc6 compiler supports msvcrt. dll and msvcrtd. DLL for debugging.

The C ++ runtime DLL of the vc6 compiler supports msvcrt60.dll and msvcrt60d. DLL for debugging.

4. Multiple running database instances

For program modules that are statically linked to the Runtime Library, regardless of the EXE or DLL, each module copies the variable and code (part) of the Runtime Library ). That is to say, each module has a runtime database instance. When there are multiple runtime database instances in the process, each runtime database instance uses its own data (variables) and resources (HEAP), which can work properly theoretically, but it may also cause problems. One of them is that the memory allocated from one CRT heap is sent to another CRT instance for release. In the debugging version, the CRT memory check function detects this problem and reports an error. However, releasing a new version will cause serious problems.

5. List of entry functions of the EXE Module

User entry function CRT entry function application

Main maincrtstartup console Program
Wmain wmaincrtstartup wide character console Program
Winmain winmaincrtstartup Win32 Application
Wwinmain wwinmaincrtstartup wide-character Win32 Application

The user portal function of the DLL module is dllmain. Because dllmain does not have a character type parameter, the portal function of the DLL module with wide characters is also dllmain.

Bool winapi dllmain (handle hdllhandle,/* module handle, that is, the base address */, DWORD dwreason/* Call reason */, lpvoid lpreserved );

(Most of the time, we start coding from main, but we don't know much about the work before and after main. I 've read windows core programming before, as I seem to have said)

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.