当我使用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());
}
}
Run Code Online (Sandbox Code Playgroud)
例外是
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 …Run Code Online (Sandbox Code Playgroud) 我有一个指向一个名为cPlayer的类的指针数组.
编译器:Visual C++ 2010 Express
在里面
cPlayer* players[MAX_PLAYERS];
Run Code Online (Sandbox Code Playgroud)
Max_Players是一个定义的值10.在标题中名为"OnlineData"的类中定义.
检查
if (players[a]){
// some code here
}
Run Code Online (Sandbox Code Playgroud)
我曾经尝试过,它仍然可以在这里找到一些代码
玩家被删除如下:
players[player->id]=0;
delete player;
Run Code Online (Sandbox Code Playgroud)
题
我想检查在players数组中位置a的项是否有值.我用它来求助玩家列表(碎片整理)
该数组在添加内容时正常工作,直到我尝试执行上述操作