加载到阵列中会导致堆栈粉碎,同时有足够的空间
Loading into Array causes Stack Smashing while having enough space?
执行以下代码时,我会收到Stack Smashing
错误。
const uint size = 62;
...
for (int i=0; i < 10; ++i){
// mask = elements != zero
// input = epi32 m512 data containing 1 byte values
_mm512_mask_compress_epi32(input, mask, input);
// get just elements != 0 as previous mask.
__mmask16 mask1 = _mm512_cmpneq_epi32_mask(compressed, _mm512_setzero_epi32());
// append the non-zero elements to the uchar*
_mm512_mask_cvtusepi32_storeu_epi8((uchar*)str+pos, mask1, compressed); // uncommenting = no error, truncating mask = no error
// add size of the inserted elements by counting 1's in mask
pos += sizeOfInsertion;
// print the position of the pointer AFTER storing
void* pp = (void*) ((uchar*) str + pos);
std::cout << pp << std::endl;
}
为了调查此问题,我在插入元素时检查了指针的位置。在开始(pointing to str[0])
时,我有0x7ffce3468d30
,最后0x7ffce3468d69
。减去这些地址我得到3E = 62
。因此,它应该安装在已声明的数组中。将蒙版移动1(截断一个元素(,不会丢失错误。
失败在压缩中。我不介意将不匹配的值归零,因此数据没有连续存储,因此堆栈溢出。
简而言之:
_mm512_maskz_compress_epi32(mask, input);
使它起作用。
相关文章:
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 命名空间中具有.h和.cpp文件的类
- 从父命名空间重载类型
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- OpenMP阵列性能较差
- 在命名空间中定义函数还是限定函数
- C++:对不存在的命名空间使用命名空间指令
- 通过继承类使用来自不同命名空间的运算符
- 如何将三维尺寸不固定的三维阵列展平为一维阵列
- 当我的阵列太大时出现分段错误
- 使用命名空间时出现多个定义错误
- OpenGL相机和相机空间转型的困惑
- CUDA内核和数学函数的显式命名空间
- 打印第二列时的2d字符矢量打印空间
- OPENCL-如何使辅助功能返回阵列并将内存的部分从恒定内存空间转移到私有
- 加载到阵列中会导致堆栈粉碎,同时有足够的空间
- 我如何使我的循环转到char*阵列的尽头,并将每个城市都放在链接的列表中(城市被划分为白色的空间)
- 使用 malloc 获取阵列空间
- 为阵列分配空间
- 动态二维阵列:空间问题