引发了异常: 读取访问权限冲突。
_Right_data 是 0xC17B1FA8。
附代码
#include <iostream>
#include<windows.h>
#include<process.h>
#include<fstream>
int main()
{
std::string outputLabelPath = "sssssss";
unsigned int iParam[4];
iParam[3] = (unsigned int)&outputLabelPath;
std::string *fileOutputPath = (std::string*)iParam[3];
std::string centerFile = *fileOutputPath;
getchar();
}
上述代码本来用于线程间通信,它在vs2017 x86的环境下没有任何问题,但是在x64环境下直接爆出:引发了异常: 读取访问权限冲突。_Right_data 是 0xB155F9D8。经过反复排查终于定位出问题所在:string * 在x86和x64环境下地址长度不一样,导致指针异常使程序崩溃,而unsigned int 地址没有任何变化。以下是不同环境下指针测试结果。
x86下32位测试结果:
x64下测试结果:
终于发现问题所在,谢谢大家。