我在我的应用程序中使用memcpy.memcpy崩溃randomely和下面是我在Dr.Watson文件中得到的日志.
100181b5 8bd1 mov edx,ecx
100181b7 c1e902 shr ecx,0x2
100181ba 8d7c030c lea edi,[ebx+eax+0xc]
100181be f3a5 rep movsd
100181c0 8bca mov ecx,edx
100181c2 83e103 and ecx,0x3
FAULT ->100181c5 f3a4 rep movsb ds:02a3b000=?? es:01b14e64=00
100181c7 ff1508450210 call dword ptr [Debug (10024508)]
100181cd 83c424 add esp,0x24
100181d0 6854580210 push 0x10025854
100181d5 ff1508450210 call dword ptr [Debug (10024508)]
100181db 83c404 add esp,0x4
Run Code Online (Sandbox Code Playgroud)
下面是代码
memcpy((char *)dep + (int)sizeof(EntryRec) + (int)adp->fileHdr.keySize, data, dataSize );
Run Code Online (Sandbox Code Playgroud)
哪里:
NULL在这种情况下不是数据有没有人遇到这个问题,可以帮助我吗?
我试图调试编程,然后我得到以下错误Prog.exe(MSVCRTD.DLL)中的未处理的异常:0xC0000005:访问voilation
数据被传递给该程序的参数,这是无效的*
更多信息:
我试过调试代码适配器在以下区域崩溃这个函数出现在OUTPUT.c中(我认为这是一个库函数)
#else /* _UNICODE */
if (flags & (FL_LONG|FL_WIDECHAR)) {
if (text.wz == NULL) /* NULL passed, use special string */
text.wz = __wnullstring;
bufferiswide = 1;
pwch = text.wz;
while ( i-- && *pwch )
++pwch;
textlen = pwch - text.wz;
/* textlen now contains length in wide chars */
} else {
if (text.sz == NULL) /* NULL passed, use special string */
text.sz = __nullstring;
p = text.sz;
while (i-- && *p) //Crash points here
++p;
textlen = p - text.sz; /* length of the string */
}
Run Code Online (Sandbox Code Playgroud)
变量值:p =""(未初始化)i = 2147483598
Mar*_*off 17
有两种非常可能的解释:
memcpy重叠的地址 - 这种情况的行为是未定义的.如果您需要处理重叠地址的能力,std::memmove则是"等效"工具.memcpy复制到程序无法访问的内存中.从您显示的代码看,(2)更可能是场景.由于您可以调试源,因此请尝试在memcpy发生之前设置断点,并验证memcpy所有参数是否匹配(即source + num < dest或source > dest + num).