大家好:
我在调试软件的时候发现一个奇怪的现象。软件在运行一段时间后,会中断到windbg调试器中,但是g之后,继续运行完全正常。我能分析出问题出现的直接原因,但是根本原因是什么呢??谁能帮我解释下这个现象?这个问题严重么?如果不对它进行处理那么当软件发布的时候会不会出现问题呢?
下面是我的分析:
经过观察发现问题出现在wdmaud模块中,感觉和录放音相关,再看下调用栈RtlGetUserInfoHeap函数的2个参数中,00140000没有问题,但是00161700却似乎存在问题,因为这个堆块的基地址是001616e8,加上8B的HEAP_ENTRY,那么用户起始地址应该是001516f0。而这里确实00161700,之后再用RtlpValidateHeapEntry去验证堆块,那肯定会出问题。
我的调试过程:
首先在调试软件时,我开启了htc hfc hpc hvc.
0:005> !gflag Current NtGlobalFlag contents: 0x000000f0 htc - Enable heap tail checking hfc - Enable heap free checking hpc - Enable heap parameter checking hvc - Enable heap validation on call
在软件运行一段时间后,出现如下提示
HEAP[SPlane.exe]: Invalid Address specified to RtlGetUserInfoHeap( 00140000, 00161700 ) (8a8.14f4): Break instruction exception - code 80000003 (first chance) eax=001616f8 ebx=001616f8 ecx=7c93d4fd edx=0152fc69 esi=00140000 edi=00161700 eip=7c92120e esp=0152fe6c ebp=0152fe70 iopl=0 nv up ei pl nz na po nc cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202 ntdll!DbgBreakPoint:
调用栈是这样的:
0:005> kv ChildEBP RetAddr Args to Child 0152fe68 7c98ee31 0152fe84 7c98f26e 001616f8 ntdll!DbgBreakPoint (FPO: [0,0,0]) 0152fe70 7c98f26e 001616f8 00140000 00000001 ntdll!RtlpBreakPointHeap+0x28 (FPO: [Non-Fpo]) 0152fe84 7c990715 00140000 001616f8 7c9907d4 ntdll!RtlpValidateHeapEntry+0x113 (FPO: [Non-Fpo]) 0152fed4 7c96d381 00140000 50000061 00161700 ntdll!RtlDebugGetUserInfoHeap+0x96 (FPO: [Non-Fpo]) 0152ff38 7c834d23 00140000 00000001 00161700 ntdll!RtlGetUserInfoHeap+0x3a (FPO: [Non-Fpo]) 0152ff84 72c922ce 00161700 7c9210e0 7c921000 kernel32!GlobalHandle+0x3a (FPO: [Non-Fpo]) 0152ff9c 72c94617 00160a20 00000004 003dea00 wdmaud!waveCompleteHeader+0x40 (FPO: [Non-Fpo]) 0152ffb4 7c80b729 00000638 00000004 003dea00 wdmaud!waveThread+0x9c (FPO: [Non-Fpo]) 0152ffec 00000000 72c9457b 00160a20 00000000 kernel32!BaseThreadStart+0x37 (FPO: [Non-Fpo])
观察堆头是有效的,但在程序中以001616f8去验证堆头,肯定会报错。
0:005> dt ntdll!_HEAP_ENTRY 001616e8 +0x000 Size : 0x14 +0x002 PreviousSize : 0x26 +0x000 SubSegmentCode : 0x00260014 Void +0x004 SmallTagIndex : 0x89 '' +0x005 Flags : 0x7 '' +0x006 UnusedBytes : 0x1c '' +0x007 SegmentIndex : 0 ''
观察下出问题的堆块是这样的:
0:005> db 001616e8 la0 001616e8 14 00 26 00 89 07 1c 00-f8 f2 4a 5f 98 fe dc 00 ..&.......J_.... 001616f8 00 00 00 00 58 00 00 00-00 00 00 00 00 08 53 01 ....X.........S. 00161708 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00161718 5e 99 42 5f 00 00 00 00-b4 f0 4a 5f 00 00 00 00 ^.B_......J_.... 00161728 11 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00161738 0a 00 00 00 b4 f0 4a 5f-00 00 00 00 11 00 00 00 ......J_........ 00161748 00 00 00 00 00 00 00 00-00 00 00 00 0a 00 00 00 ................ 00161758 50 f0 4a 5f 00 00 00 00-00 00 00 00 00 00 00 00 P.J_............ 00161768 00 00 00 00 00 00 00 00-0a 00 00 00 ab ab ab ab ................ 00161778 ab ab ab ab ee fe ee fe-00 00 00 00 00 00 00 00
|