我遇到这种奇怪的崩溃,只有在启用时才会发生。我很确定这是某种堆栈损坏,但崩溃的细节非常奇怪。
void CMover::UpdateParts(int nSex, int nSkinSet, int nFace, int nHairMesh, int nHeadMesh,
PEQUIP_INFO pEquipInfo, CModelObject* pModel, ItemContainer* pEquipment, BOOL bIfParts,
CMover* pMover)
{
if (pModel == nullptr) // returns false, aka in runtime, the pModel pointer isn't being evaluated to 0
{
MooLog::Write("CMover::UpdateParts : pModel is nullptr");
return;
}
if (bIfParts)
{
// if I uncomment the following line, it won't crash for some reason
//MooLog::Write("CMover::UpdateParts : pModel is %08X", 3);
// Crashes on the following line accessing invalid memory(0x000000C0, which is the offset of m_nPartsIdx)
// It's strange that pModel is evaluating to zero here, considering it was just checked a few lines prior.
pModel->m_nPartsIdx = 0;
}
...
}
假设单线程应用程序,看到在此崩溃时没有其他线程会写入。使用VC11 x86进行编译。