Debug method for Windows wild pointers

Source: Internet
Author: User

Project, there was an inexplicable crash with the error:

XXXX modified at Xxxafter it is freed

The breakpoint position is in a destructor, and after checking, this class is not a problem, it is not a class that the destructor has been refactored.

Pain, searching for a tool: Gfrag.exe

Call:./gflags.exe-p/enable Program name. Exe/full you do not need to specify a specific path here.

This tool is actually just setting up the registry that will:

Computer \hkey_local_machine\software\microsoft\windows nt\currentversion\image File execution options\ program name. EXE to set a

GlobalFlag REG_SZ 0x02000000

PageHeapFlags REG_SZ 0x3

So you can also set your own hand. When the shell runs the program, it uses the full page heap for program memory allocation, which causes an exception when wild pointer access or cross-border access occurs.

If you do not set this, wild pointer access and out-of-bounds access does not cause an exception, so it does not crash on the spot, but crashes in the next free or malloc call, making it impossible to find out.

The following is a very successful discovery: A variable type has changed, but the pointer declared in the code is still old, calling the functions of different classes, and then looking for out-of-scope memory.

Debug method for Windows wild pointers

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.