Closed
【缺陷报告】数组索引越界 - 文件kernel_operator_data_copy_impl.h - 函数DataCopySliceGm2UBImpl - 行号551 #1541
zhangjunkai9Add on Aug 19Closed at Aug 19
Aug 19 Assign zhudi22 as responsible person
Aug 19 Associated pull request
Aug 19 Close issue
Aug 19 Added label: resolved
缺陷信息
缺陷描述
DataCopySliceGm2UBImpl 中偏移量累积公式 offsetSrc = offsetSrc + i * (blockLen * ONE_BLK_SIZE + srcStride) 存在错误:每次迭代累加 i*stride 而非 stride,导致偏移量以三角数增长(0, S, 3S, 6S, 10S...),而非预期的线性增长(0, S, 2S, 3S...)。当 blockCount>=3 时偏移量将超出预期,导致 dst + offsetDst/sizeof(T) 和 src + offsetSrc/sizeof(T) 指针越界访问。正确公式应为 offsetSrc += (blockLen * ONE_BLK_SIZE + srcStride) 或 offsetSrc = i * (blockLen * ONE_BLK_SIZE + srcStride)。
数据流证据
传播路径:
修复建议
for (uint32_t i = 0; i < intriParams.blockCount; i++) { offsetSrc += intriParams.blockLen * ONE_BLK_SIZE + intriParams.srcStride; offsetDst += intriParams.blockLen * ONE_BLK_SIZE + intriParams.dstStride; DataCopyGM2UBImpl(dst + offsetDst / sizeof(T), src + offsetSrc / sizeof(T), {1, intriParams.blockLen, 0, 0}); }