4
我試圖調試崩潰。 (ACCESS_VIOLATION)
分析崩潰 - 將反彙編指令翻譯爲C++等效
下面是一個反彙編代碼片段。我標記了發生異常的行。 它對應於下面顯示的實際C++代碼中的那條指令嗎?
拆卸:
420: for(Uint32 i = 0; i < m_children.size(); ++i){
06A923D3 8B 46 0C mov eax,dword ptr [esi+0Ch]
06A923D6 57 push edi
06A923D7 33 FF xor edi,edi
--> 06A923D9 39 38 cmp dword ptr [eax],edi
06A923DB 76 59 jbe ICategoryNode::iterate+66h (6A92436h)
06A923DD 53 push ebx
06A923DE 55 push ebp
06A923DF 8B 2D 04 60 B0 06 mov ebp,dword ptr [__imp_::AssertionFailure::logAssert (6B06004h)]
06A923E5 33 DB xor ebx,ebx
421: bool keepGoing = CategoryImp::recursiveIterator(handler, *m_children[i]);
實際C++代碼:
void ICategoryNode::iterate(ICategoryHandler& handler) const {
for(Uint32 i = 0; i < m_children.size(); ++i) {
bool keepGoing = CategoryImp::recursiveIterator(handler, *m_children[i]);
if(!keepGoing)
return;
}
}
您是否暗示'this'必須爲空,因爲使用'm_children'會導致異常?我編輯了代碼以明確它已經進入成員函數的事實(因此'this'是有效的)。 –
不,我的意思是'這個'是無效的。即,你調用了'ptr-> iterate(something)',其中'ptr'爲NULL,或者未初始化,或者已經被刪除,否則無效。 m_children不是一個指針,所以它不能爲NULL。 – bdonlan
@dominus:你爲什麼聲稱'this'只有在你進入成員函數時纔有效?成員函數是虛擬的嗎?如果沒有,你沒有理由相信你的'this'指針。我同意bdonlan。 – TonyK