已关闭
【缺陷报告】数据类型截断 - 文件brc_inline_api.h - 函数BinaryBrcInlineApiWithTwoVectorizedAxis - 行号43 #258
zhangjunkai9创建于 20 天前关闭于 4 天前
20 天前 将 gcw_V3YyYBt1 设为负责人
wangmingming
20 天前 评论:
20 天前 评论:
你好,感谢建议, 后续分析处理


12 天前 关联了pull request:fix: 修复 Gather 回绕及 BrcInline/Cast/Concat 截断(#256 #258 #259 #260)
4 天前 issue状态由 进行中 改变为 已完成
4 天前 关闭了 issue
缺陷信息
缺陷描述
函数 BinaryBrcInlineApiWithTwoVectorizedAxis 的入参 first_axis_v_stride(int64_t)在第43行除以 elem_in_one_block(int64_t,=32/dtype_size)后,结果直接赋值给 uint8_t dst_repeat_stride。该值用作硬件指令 BinaryRepeatParams 的 dst_repeat_stride 参数(8位字段)。当 first_axis_v_stride 超过 255*elem_in_one_block(如 float 类型时 255*8=2040 个元素)时,除法结果超过 255,高位被截断,导致硬件使用错误的 stride 值。代码中虽有 while(block>255) 循环处理 repeat times 溢出,但对 stride 参数无任何范围检查。调用方(codegen/binary_api_call.cpp:172)传入 tpipe.tiler.ActualSize(v_strides) 作为 stride 值,无范围保证。
事实核查
数据流证据
传播路径:
调用链
可达调用链1 起点:
(entry functions)→ 终点:BinaryBrcInlineApiWithTwoVectorizedAxis深度:0修复建议
uint32_t dst_repeat_stride_full = static_cast<uint32_t>(first_axis_v_stride / elem_in_one_block); ASCENDC_ASSERT(dst_repeat_stride_full <= UINT8_MAX, { KERNEL_LOG(KERNEL_ERROR, "dst_repeat_stride exceeds 255: %u", dst_repeat_stride_full); }); uint8_t dst_repeat_stride = static_cast<uint8_t>(dst_repeat_stride_full);