我正在使用windbg调试软件Use-After-Free错误(不能访问源代码)。
哪里
An Object Created --(do something)--> Object Deleted --(do something)--> Object Reference Re-used [App. CRASHHHH!!!]
使用windbg和' PageHeap'我可以很容易地找出该对象何时被释放(!heap -p -a 0xXXXXXXX)并重新使用。
我的问题是,在创建该对象时,有哪些方法可以找到它。
THX
答案 0 :(得分:3)
您可以使用的一个巧妙的技巧是使用(好吧,可能是滥用)泄漏跟踪来保存分配堆栈跟踪并在调试器中查看它们。
由于你已经启用了pageheap,这应该很容易解释。
gflags.exe
(Windbg附带)并更改流程图像文件的标记。Enable page heap
和Create user mode stack trace database
的复选框,然后点击“应用”。 !heap -p -a <allocation address you want the callstack of>
我在notepad.exe
堆栈中的一个堆分配上运行它并得到了这个:
0:000> !heap -p -a 00000261`1a43b6c8
address 000002611a43b6c8 found in
_DPH_HEAP_ROOT @ 26119821000
in busy allocation ( DPH_HEAP_BLOCK: UserAddr UserSize - VirtAddr VirtSize)
26119847750: 2611a43b6c0 938 - 2611a43b000 2000
COMDLG32!CFileOpenSave::`vftable'
00007ffa890622c7 ntdll!RtlDebugAllocateHeap+0x0000000000000047
00007ffa88ff79ce ntdll!RtlpAllocateHeap+0x00000000000000ee
00007ffa88ff595f ntdll!RtlpAllocateHeapInternal+0x000000000000064f
00007ffa884c0f38 COMDLG32!CFileOpenSave::s_CreateInstance+0x0000000000000088
00007ffa884d6750 COMDLG32!`CommonPrintDialogTelemetry::Instance'::`2'::`dynamic atexit destructor for 'wrapper''+0x00000000000103c0
00007ffa886ffee7 combase!CServerContextActivator::CreateInstance+0x0000000000000207 [d:\th\com\combase\objact\actvator.cxx @ 872]
00007ffa8876c0b3 combase!ActivationPropertiesIn::DelegateCreateInstance+0x00000000000000e3 [d:\th\com\combase\actprops\actprops.cxx @ 1926]
00007ffa88700687 combase!CApartmentActivator::CreateInstance+0x00000000000000c7 [d:\th\com\combase\objact\actvator.cxx @ 2168]
00007ffa886ff3e9 combase!CProcessActivator::CCICallback+0x0000000000000079 [d:\th\com\combase\objact\actvator.cxx @ 1631]
00007ffa886ff504 combase!CProcessActivator::AttemptActivation+0x0000000000000064 [d:\th\com\combase\objact\actvator.cxx @ 1518]
00007ffa886ff5e0 combase!CProcessActivator::ActivateByContext+0x00000000000000b0 [d:\th\com\combase\objact\actvator.cxx @ 1364]
00007ffa886ff900 combase!CProcessActivator::CreateInstance+0x0000000000000090 [d:\th\com\combase\objact\actvator.cxx @ 1262]
00007ffa8876c104 combase!ActivationPropertiesIn::DelegateCreateInstance+0x0000000000000134 [d:\th\com\combase\actprops\actprops.cxx @ 1926]
00007ffa8876929a combase!CClientContextActivator::CreateInstance+0x000000000000015a [d:\th\com\combase\objact\actvator.cxx @ 561]
00007ffa8876c0c6 combase!ActivationPropertiesIn::DelegateCreateInstance+0x00000000000000f6 [d:\th\com\combase\actprops\actprops.cxx @ 1978]
00007ffa88760c61 combase!ICoCreateInstanceEx+0x0000000000000c91 [d:\th\com\combase\objact\objact.cxx @ 1817]
00007ffa8875fea7 combase!CComActivator::DoCreateInstance+0x0000000000000147 [d:\th\com\combase\objact\immact.hxx @ 376]
00007ffa8875fd0c combase!CoCreateInstance+0x000000000000019c [d:\th\com\combase\objact\actapi.cxx @ 120]
00007ff6d5321be8 notepad!InvokeOpenDialog+0x000000000000004c
00007ff6d53225d7 notepad!NPCommand+0x00000000000003b7
00007ff6d53238a9 notepad!NPWndProc+0x0000000000000509
00007ffa88a41169 USER32!UserCallWinProcCheckWow+0x00000000000001f9
00007ffa88a40c97 USER32!DispatchMessageWorker+0x00000000000001a7
00007ff6d5323ba1 notepad!WinMain+0x0000000000000269
00007ff6d53390b5 notepad!WinMainCRTStartup+0x00000000000001c5
00007ffa866c8102 KERNEL32!BaseThreadInitThunk+0x0000000000000022
00007ffa8902c2e4 ntdll!RtlUserThreadStart+0x0000000000000034
如果您没有获得堆栈跟踪,则要尝试的一件事是增加堆栈回溯数据库的大小。