已关闭
【缺陷报告】容器访问越界 - 文件ins_reduce_scatter_concurrent_executor.cc - 函数CalcRes - 行号46 #1546
zhangjunkai9创建于  26 天前关闭于  23 天前
zhangjunkai9
26 天前 创建

缺陷信息

缺陷类型containerOutOfBounds (容器访问越界)
函数CalcRes
文件impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc
行号46

缺陷描述

函数 CalcRes 在第42行检查 algHierarchyInfo.infos.size()==0 后仅打印 HCCL_ERROR 日志但未 return,导致执行继续到第46行访问 algHierarchyInfo.infos[0][0] 和第47行访问 algHierarchyInfo.infos[0][1]。若 infos 为空则 vector 越界访问导致未定义行为;即使 infos 非空,infos[0] 内部 vector 也可能为空导致二次越界。空检查后缺少 return 是明确的逻辑缺陷。

数据流证据

Source(问题源头)

impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc:34 行 const AlgHierarchyInfoForAllLevel& algHierarchyInfo 作为函数入参传入(其 infos 字段可能为空)

Sink(问题爆发点)

impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc:46 行 algHierarchyInfo.infos[0][0] 直接访问(infos 为空时越界)

传播路径:

# 文件 行号 说明
1 impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc 34 algHierarchyInfo 作为函数入参接收(无非空保证)
2 impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc 42 if (algHierarchyInfo.infos.size() == 0) 检测到空但仅打印日志未 return,保护无效
3 impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc 46 algHierarchyInfo.infos[0][0] 在保护无效后直接访问(sink)
4 impl/adv_api/detail/hccl/cc/src/ops/reduce_scatter/executor/ins_reduce_scatter_concurrent_executor.cc 47 algHierarchyInfo.infos[0][1] 同样无保护访问(sink)

修复建议

if (algHierarchyInfo.infos.size() == 0) {
    HCCL_ERROR("[InsReduceScatterConcurrentExecutor] algHierarchyInfo has no members, Please check the algHierarchyInfo!");
    return HcclResult::HCCL_E_INTERNAL;
}
likedislike
shaonaiteshaonaite成员
26 天前 将 jiangxinyu3 设为负责人
shaonaiteshaonaite成员
26 天前 移除了负责人 jiangxinyu3
shaonaiteshaonaite成员
26 天前 将 liragnarosf 设为负责人
shaonaiteshaonaite成员
26 天前 移除了负责人 liragnarosf
shaonaiteshaonaite成员
25 天前 将 zhengchao0613 设为负责人
zc1110
zc1110成员
25 天前 评论:

您好,已收到该问题,可以关注后续修改Pr

likedislike
zc1110zc1110成员
25 天前 关联了pull request:fix dts
zc1110zc1110成员
23 天前 issue状态由 进行中 改变为 已完成
zc1110zc1110成员
23 天前 关闭了 issue
CANN-robotCANN-robot成员
23 天前 添加了label:resolved