Windbug find debug program memory overflow

Source: Internet
Author: User

To debug the program compiled by debug and release, set relevant properties. Otherwise, the program under release cannot be located in windbgtest by default! Ttss: XXXXX

Add the following settings to the vs2008 release:

C/C ++-> Optimization-> optimization: Disable (/0d)

C/C ++-> Optimization-> program optimization: No

C/C ++-> General-> debugging information format: The program database/Zi used to "edit and continue"

Linker-> debug-> Generate a program database file: $ (targetdir) $ (targetname). PDB


In addition: First open the program, and keep the. PDB file generated by the program, and then attach windbug to the specified program

The program source code is as follows:

Subclass:

Void ttss: XXXXX (void)
{
Char * temp = (char *) malloc (10000); // new char [20000];
}

Parent class:

Bool cwindbgtestdlg: oninitdialog ()
{
Cdialog: oninitdialog ();
_ Ttss = new ttss ();
Return true;
}

Void cwindbgtestdlg: onbnclickedbutton1 ()
{
_ Ttss-> XXXXX ();
}

Perform the following operations on gflags.exe:

The windbug debugging information is as follows:

Warning: whitespace at start of path element
* ** Wait with pending attach
Symbol search path is: SRV * c: \ Program Files \ windows \ symbols * http://msdl.microsoft.com/download/symbols#c:#program files \ windows \ symbols
Executable search path is:
Modload: 00400000 0043a000 F: \ test \ windbgtest \ debug \ windbgtest.exe
Modload: 7c920000 7c9b6000 c: \ windows \ system32 \ NTDLL. dll
Modload: 7c800000 7c91e000 c: \ windows \ system32 \ kernel32.dll
Modload: 785e0000 78b8f000 c: \ windows \ winsxs \ x86_Microsoft.VC90.DebugMFC_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_c94a3a24 \ mfc90d. dll
Modload: 10200000 10323000 c: \ windows \ winsxs \ x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f \ msvcr90d. dll
Modload: 77d10000 77da0000 c: \ windows \ system32 \ user32.dll
Modload: 77ef0000 77f39000 c: \ windows \ system32 \ gdi32.dll
Modload: 77f40000 77fb6000 c: \ windows \ system32 \ shlwapi. dll
Modload: 77da0000 77e49000 c: \ windows \ system32 \ advapi32.dll
Modload: 77e50000 77ee2000 c: \ windows \ system32 \ rpcrt4.dll
Modload: 77fc0000 77fd1000 c: \ windows \ system32 \ secur32.dll
Modload: 77be0000 77c38000 c: \ windows \ system32 \ msvcrt. dll
Modload: 5d170000 5d20a000 c: \ windows \ system32 \ comctl32.dll
Modload: 762f0000 762f5000 c: \ windows \ system32 \ msimg32.dll
Modload: 770f0000 7717b000 c: \ windows \ system32 \ oleaut32.dll
Modload: 76990000 76ace000 c: \ windows \ system32 \ ole32.dll
Modload: 76300000 7631d000 c: \ windows \ system32 \ imm32.dll
Modload: 62c20000 62c29000 c: \ windows \ system32 \ LPK. dll
Modload: 73fa0000 7400b000 c: \ windows \ system32 \ usp10.dll
Modload: 5adc0000 5adf7000 c: \ windows \ system32 \ uxtheme. dll
Modload: 7d590000 7dd84000 c: \ windows \ system32 \ shell32.dll
Modload: 77180000 77283000 c: \ windows \ winsxs \ x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202 \ comctl32.dll
Modload: 5d360000 5d0000000 c: \ windows \ winsxs \ x86_Microsoft.VC90.MFCLOC_1fc8b3b9a1e18e3b_9.0.30729.4974_x-ww_19f00fd4 \ mfc90chs. dll
Modload: 67340000 6747e000 c: \ Program Files \ 360 \ 360safe \ safemon. dll
Modload: 76bc0000 76bcb000 c: \ windows \ system32 \ psapi. dll
Modload: 3e410000 3e4e3000 c: \ windows \ system32 \ wininet. dll
Modload: 01eb0000 01eb9000 c: \ windows \ system32 \ normaliz. dll
Modload: 3eab0000 3eaf5000 c: \ windows \ system32 \ iertutil. dll
Modload: 77bd0000 77bd8000 c: \ windows \ system32 \ version. dll
Modload: 71a20000 71a37000 c: \ windows \ system32 \ ws2_32.dll
Modload: 71a10000 71a18000 c: \ windows \ system32 \ ws2help. dll
Modload: 5fdd0000 5fe25000 c: \ windows \ system32 \ netapi32.dll
Modload: 74680000 746cc000 c: \ windows \ system32 \ msctf. dll
Modload: 73640000 7366e000 c: \ windows \ system32 \ msctfime. ime
Modload: 02280000 02563000 c: \ windows \ system32 \ sogoupy. ime
Modload: 10000000 1008c000 c: \ Program Files \ sogouinput \ Components \ picface \ 1.0.0.730 \ picface. dll
Modload: 76cb0000 76cd0000 c: \ windows \ system32 \ ntmarta. dll
Modload: 71b70000 71b83000 c: \ windows \ system32 \ samlib. dll
Modload: 76f30000 76f5c000 c: \ windows \ system32 \ wldap32.dll
Modload: 06490000 064df000 c: \ Program Files \ sogouinput \ Components \ addresssearch \ 1.0.0.1158 \ addresssearch. dll
(1d0. 16f0): Break instruction exception-code 80000003 (first chance)
Eax = 7ffd5000 EBX = 00000001 ECx = 00000002 edX = 00000003 ESI = 00000004 EDI = 00000005
EIP = 7c92120e ESP = 05 daffcc EBP = 05dafff4 iopl = 0 NV up ei pl Zr na PE NC
Cs = 001b Ss = 0023 DS = 0023 es = 0023 FS = 0038 GS = 0000 EFL = 00000246
Ntdll! Dbgbreakpoint:
7c92120e cc int 3
0: 004> G
(1d0. F20): Break instruction exception-code 80000003 (first chance)
Eax = 7ffd5000 EBX = 00000001 ECx = 00000002 edX = 00000003 ESI = 00000004 EDI = 00000005
EIP = 7c92120e ESP = 05 daffcc EBP = 05dafff4 iopl = 0 NV up ei pl Zr na PE NC
Cs = 001b Ss = 0023 DS = 0023 es = 0023 FS = 0038 GS = 0000 EFL = 00000246
Ntdll! Dbgbreakpoint:
7c92120e cc int 3
0: 002>! Heap-s (*** execute this statement multiple times to find out the heap program in which memory usage is growing: 0x0390000 ***)
Ntglobalflag enables following debugging aids for new heaps:
Validate parameters
Stack back traces
Heap flags reserv commit virt Free List UCR virt lock fast
(K) length blocks Cont. Heap
-----------------------------------------------------------------------------
00150000 58000062 1024 96 96 12 2 1 0 0 l
00250000 58001062 64 24 24 8 1 1 0 0 l
00260000 58008060 64 12 12 10 1 1 0 0
00390000 58001062 1088 296 296 13 2 2 0 0
003b0000 58001062 1088 544 544 26 2 2 0 0 l
003e0000 58001062 64 24 24 2 1 1 0 0 l
003f0000 58001062 64 20 20 4 1 1 0 0 l
01ec0000 58000062 1024 24 24 3 1 1 0 0 l
020d0000 58001062 256 12 12 4 1 1 0 0 l
02110000 58001062 1088 56 56 37 2 2 0 l
02580000 58001062 3136 796 852 59 5 5 0 l
061c0000 58001062 1088 112 57 4 2 0 0 l
064f0000 58001062 64 52 52 3 1 1 0 0 l
-----------------------------------------------------------------------------
0: 002>! Heap-stat-H 0390000 open the specified heap Information
Heap @ 00390000
Group-by: totsize max-display: 20
Size # Blocks total (%) (percent of total busy bytes)
4e44 C-3ab30 (85.11)
1035 2-20 6a (2.94)
1800 1 to 1800 (2.17)
1528 1 to 1528 (1.92)
824, 2-1048 (1.48)
238 4-8e0 (0.80)
228, 3-678 (0.59)
37 1A-596 (0.51)
424 1 to 424 (0.38)
385 1 to 385 (0.32)
80, 6, 300 (0.27)
A0 4-280 (0.23)
244 1 to 244 (0.21)
3A 9-20a (0.18)
40 8 to 200 (0.18)
38 8-1c0 (0.16)
58 5-1 B8 (0.16)
41 6-186 (0.14)
44, 4-110 (0.10)
42 4-108 (0.09)
0: 002>! Heap-FLT s 4e44 displays the memory information of the specified size area
_ Heap @ 150000
_ Heap @ 250000
_ Heap @ 260000
_ Heap @ 390000
Heap_entry size Prev flags userptr usersize-state
05e30040 09cc 0000 [07] 05e30048 04e44-(busy)
05e34ea0 09cc 09cc [07] 05e34ea8 04e44-(busy)
05e39d00 09cc 09cc [07] 05e39d08 04e44-(busy)
05e3eb60 09cc 09cc [07] 05e3eb68 04e44-(busy)
05e439c0 09cc 09cc [07] 05e439c8 04e44-(busy)
05e48820 09cc 09cc [07] 05e48828 04e44-(busy)
05e4d680 09cc 09cc [07] 05e4d688 04e44-(busy)
05e524e0 09cc 09cc [07] 05e524e8 04e44-(busy)
05e57340 09cc 09cc [07]05e5734804e44-(busy)
05e5c1a0 09cc 09cc [07] 05e5c1a8 04e44-(busy)
05e61000 09cc 09cc [07] 05e61008 04e44-(busy)
05e65e60 09cc 09cc [07] 05e65e68 04e44-(busy)
_ Heap @ 3b0000
_ Heap @ 3e0000
_ Heap @ 3f0000
_ Heap @ 1ec0000
_ Heap @ 20d0000
_ Heap @ 2110000
_ Heap @ 2580000
_ Heap @ 61c0000
_ Heap @ 64f0000
0: 002>! Heap-p-A 05e57348Display page heap information related to the specified memory address(Any userptr can be selected here)
Address 05e57348 found in
_ Heap @ 390000
Heap_entry size Prev flags userptr usersize-state
05e57340 09cc 0000 [07] 05e57348 04e44-(busy)
Trace: 0852
7c98fbca NTDLL! Rtldebugallocateheap + 0x000000e1
7c96b244 NTDLL! Rtlallocateheapslowly + 0x00000044
7c939c0c NTDLL! Rtlallocateheap + 0x00000e64
102c103e msvcr90d! _ Heap_alloc_base + 0x0000005e
102cfd76 msvcr90d! _ Heap_alloc_dbg_impl + 0x000001f6
102cfb2f msvcr90d! _ Nh_malloc_dbg_impl + 0x0000001f
102 cfadc msvcr90d! _ Nh_malloc_dbg + 0x0000002c
102cfa91 msvcr90d! _ Malloc_dbg + 0x00000021
78651520 mfc90d! Operator New + 0 x0 00000020
7865158e mfc90d! Operator new [] + 0x0000000e

4122cd windbgtest! Ttss: XXXXX + 0x0000002d
41323e windbgtest! Cwindbgtestdlg: onbnclickedbutton1 + 0x0000002e

786d7072 mfc90d! _ Afxdispatch1_msg + 0x000000b2
786d77ba mfc90d! C0000target: on0000msg + 0x000002ea
786ad5f3 mfc90d! Cdialog: on1_msg + 0x00000023
786709d4 mfc90d! Cwnd: oncommand + 0x00000174
7866f649 mfc90d! Cwnd: onwndmsg + 0x00000079
7866f592 mfc90d! Cwnd: windowproc + 0x00000032
7866ca10 mfc90d! Afxcallwndproc + 0x000000f0
7866cfd6 mfc90d! Afxwndproc + 0x000000a6
7866879b mfc90d! Afxwndprocbase + 0x0000005b
77d18734 USER32! Internalcallwinproc + 0x00000028
77d18816 USER32! Usercallwinproccheckwow + 0x00000150
77d2927b USER32! Sendmessageworker + 0x000004a5
77d292e3 USER32! Sendmessagew + 0x0000007f
77d4ff7d USER32! Xxxbuttonpolicyparent + 0x00000041
77d1_d2 USER32! Xxxbnreleasecapture + 0x000000f8
77d25e94 USER32! Buttonwndprocworker + 0x000006df
77d3b082 USER32! Buttonwndproca + 0x0000005d
77d18734 USER32! Internalcallwinproc + 0x00000028
77d18816 USER32! Usercallwinproccheckwow + 0x00000150
77d189cd USER32! Dispatchmessageworker + 0x00000306

 

For programs compiled by debug and release, you must set relevant attributes with all your heart; otherwise, the programs under release cannot be located in windbgtest by default! Ttss: XXXXX

Add the following settings to the vs2008 release:

C/C ++-> Optimization-> optimization: Disable (/0d)

C/C ++-> Optimization-> program optimization: No

C/C ++-> General-> debugging information format: The program database/Zi used to "edit and continue"

Linker-> debug-> Generate a program database file: $ (targetdir) $ (targetname). PDB

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.