当我使用 Visual C++ 2010 Express 的调试器运行程序 (server.exe) 时,它运行良好,但是当我将它作为 exe 运行时,它却没有;它因“Server.exe 已停止工作”对话框而崩溃。
接下来,我将 exe 重命名为“ServerInstaller.exe”并且它可以工作,所以我认为这是一个权限错误,但它不适用于管理员模式下的“Server.exe”。
然后,我将 VC++ 中的调试器附加到“Server.exe”程序,它在“free.c”中出现异常。
这个文件中的代码是
void __cdecl _free_base (void * pBlock)
{
int retval = 0;
if (pBlock == NULL)
return;
RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));
retval = HeapFree(_crtheap, 0, pBlock); // Exception thrown in this function
if (retval == 0)
{
errno = _get_errno_from_oserr(GetLastError());
}
}
例外是
Server.exe 中 0x770ae3be 处的未处理异常:0xC0000005:访问冲突读取位置 0x3765f8c7。
我检查了 pBlock 的值,它是 0x007f82c0。
我的程序。
我的程序是一个RakNet服务器,刚刚成功删除了一个播放器。服务器此时正在检查来自 RakNet 的消息
堆栈回溯
ntdll.dll!770ae3be()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!770ae023()
kernel32.dll!75e814dd()
> msvcr100d.dll!_free_base(void * pBlock) Line 50 + 0x13 bytes C
msvcr100d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1431 + 0x9 bytes C++
msvcr100d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 + 0xd bytes C++
msvcr100d.dll!free(void * pUserData) Line 49 + 0xb bytes C++
RakNetDebug.dll!RakNet::_RakFree_Ex(void * p, const char * file, unsigned int line) Line 165 + 0xc bytes C++
RakNetDebug.dll!RakNet::ReliabilityLayer::FreeInternalPacketData(RakNet::InternalPacket * internalPacket, const char * file, unsigned int line) Line 3766 + 0x17 bytes C++
RakNetDebug.dll!RakNet::ReliabilityLayer::RemovePacketFromResendListAndDeleteOlderReliableSequenced(RakNet::uint24_t messageNumber, unsigned __int64 time, DataStructures::List<RakNet::PluginInterface2 *> & messageHandlerList, const RakNet::SystemAddress & systemAddress) Line 2391 C++
RakNetDebug.dll!RakNet::ReliabilityLayer::HandleSocketReceiveFromConnectedPlayer(const char * buffer, unsigned int length, RakNet::SystemAddress & systemAddress, DataStructures::List<RakNet::PluginInterface2 *> & messageHandlerList, int MTUSize, unsigned int s, RakNet::RakNetRandom * rnr, unsigned short remotePortRakNetWasStartedOn_PS3, unsigned int extraSocketOptions, unsigned __int64 timeRead, RakNet::BitStream & updateBitStream) Line 776 C++
RakNetDebug.dll!RakNet::ProcessNetworkPacket(RakNet::SystemAddress systemAddress, const char * data, const int length, RakNet::RakPeer * rakPeer, RakNet::RakNetSmartPtr<RakNet::RakNetSocket> rakNetSocket, unsigned __int64 timeRead, RakNet::BitStream & updateBitStream) Line 5012 C++
RakNetDebug.dll!RakNet::RakPeer::RunUpdateCycle(unsigned __int64 timeNS, unsigned __int64 timeMS, RakNet::BitStream & updateBitStream) Line 5099 + 0x81 bytes C++
RakNetDebug.dll!RakNet::UpdateNetworkLoop(void * arguments) Line 5868 C++
msvcr100d.dll!_callthreadstartex() Line 314 + 0xf bytes C
msvcr100d.dll!_threadstartex(void * ptd) Line 297 C
kernel32.dll!75e833aa()
ntdll.dll!770b9ef2()
ntdll.dll!770b9ec5()