Closed
【缺陷报告】空指针解引用 - 文件moe_distribute_dispatch_v2_tiling_arch35.cpp - 函数MoeDistributeDispatchV2TilingFuncA5::MoeDistributeDispatchTilingFuncImpl - 行号1248 #4776
zhangjunkai9Add on Aug 31Closed at Sep 14
weihao18
Sep 1 Comments:
Sep 1 Comments:
你好,建议汇总到具体算子进行集中处理


游震
Sep 3 Comments:
Sep 3 Comments:
/assign @tgwsakiko_


Sep 3 Assign tgwsakiko_ as responsible person
Sep 12 Associated pull request
Sep 14 Close issue
Sep 14 Added label: resolved
缺陷信息
缺陷描述
函数 MoeDistributeDispatchV2TilingFuncA5::MoeDistributeDispatchTilingFuncImpl 在第1244行通过 attrs->GetAttrPointer(ATTR_COMM_ALG_INDEX) 获取 commAlgPtr 指针。GetAttrPointer 对未设置的属性可返回 nullptr。开发者在第1247行通过短路或 (commAlgPtr == nullptr) || (std::strlen(commAlgPtr) == 0) 安全地计算了 isNullOrEmpty,证明其知晓 commAlgPtr 可能为 nullptr(第1256行注释也明确写道 "Nullptr and empty char* are also allowed")。然而第1248-1251行在 isNullOrEmpty 计算之后,仍无条件调用 std::strcmp(commAlgPtr, ...),这些 strcmp 调用没有任何空指针保护。当 commAlgPtr 为 nullptr 时,strcmp 内部解引用第一个参数 nullptr,导致空指针解引用崩溃。该函数通过 IMPL_OP_OPTILING(MoeDistributeDispatchV2) 注册的入口函数 MoeDistributeDispatchV2TilingFuncImpl(第1363行)经 MoeDistributeDispatchV2TilingFunc(第1297行)可达,路径真实可触发。
事实核查
数据流证据
传播路径:
调用链
可达调用链1 起点:
(entry functions)→ 终点:optiling::MoeDistributeDispatchV2TilingFuncA5::MoeDistributeDispatchTilingFuncImpl深度:2修复建议
// 检查 commAlg 参数合法性校验 bool isNullOrEmpty = (commAlgPtr == nullptr) || (std::strlen(commAlgPtr) == 0); bool isFullmeshV1 = isNullOrEmpty || (std::strcmp(commAlgPtr, "fullmesh_v1") == 0); bool isFullmeshV2 = (!isNullOrEmpty) && (std::strcmp(commAlgPtr, "fullmesh_v2") == 0); bool isMte = isFullmeshV1 || isFullmeshV2; bool isCcu = (!isNullOrEmpty) && (std::strcmp(commAlgPtr, "ccu") == 0);