已关闭
【缺陷报告】空指针解引用 - 文件aclnn_remainder.cpp - 函数BroadcastTensor - 行号378 #2773
zhangjunkai9创建于  21 天前关闭于  18 天前
zhangjunkai9
21 天前 创建

缺陷信息

缺陷类型nullptrDeref (空指针解引用)
函数BroadcastTensor
文件math/floor_mod/op_api/aclnn_remainder.cpp
行号378
置信度95%

缺陷描述

第374行l0op::ReFormat返回值x可能为nullptr,第375-377行仅打印错误日志但未return。程序继续执行到第378行x->GetViewShape(),对空指针x解引用导致崩溃。缺陷模式明确:null检查后仅日志未return,后续直接解引用。BroadcastTensor被ExecRemainderTensorTensorGetWorkspaceSize在第545/547行调用,路径可达。

事实核查

经复核aclnn_remainder.cpp第370-392行源码确认,BroadcastTensor函数在第374行调用l0op::ReFormat后,第375-377行检测到nullptr仅打印OP_LOGE日志但未return,程序继续执行到第378行x->GetViewShape(),对空指针x解引用。

缺陷模式明确:null-check后缺return导致空指针解引用。

该函数在同文件第545/547行被ExecRemainderTensorTensorGetWorkspaceSize调用,路径可达。

注意:提供的call_sites指向aclnn_linalg_cross.cpp中的同名但不同签名的BroadcastTensor(3参数),与缺陷函数(4参数)无关,但缺陷函数在同文件内部确实被调用。

缺陷真实存在。

数据流证据

Source(问题源头)

math/floor_mod/op_api/aclnn_remainder.cpp:374 行 x = l0op::ReFormat(x, op::Format::FORMAT_ND) ReFormat返回nullptr表示格式转换失败

Sink(问题爆发点)

math/floor_mod/op_api/aclnn_remainder.cpp:378 行 x->GetViewShape() 对可能为nullptr的x解引用(空指针解引用sink)

传播路径:

# 文件 行号 说明
1 math/floor_mod/op_api/aclnn_remainder.cpp 374 x = l0op::ReFormat(x, op::Format::FORMAT_ND) ReFormat可能返回nullptr
2 math/floor_mod/op_api/aclnn_remainder.cpp 375-377 if (x == nullptr) { OP_LOGE(...) } 检测到空指针但仅打印日志,缺少return
3 math/floor_mod/op_api/aclnn_remainder.cpp 378 if (x->GetViewShape() != out->GetViewShape()) 对未返回的空指针x解引用(sink)
4 math/floor_mod/op_api/aclnn_remainder.cpp 545 selfContiguous = BroadcastTensor(selfContiguous, out, broadcastShape, uniqueExecutor.get()) 调用方入口,路径可达

修复建议

x = l0op::ReFormat(x, op::Format::FORMAT_ND);
if (x == nullptr) {
    OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Before broadcast, Reformat result is nullptr.");
    return nullptr;
}
likedislike
陈思
陈思成员
21 天前 评论:

根因确认

已核对当前 master。Remainder 的 BroadcastTensor 中,ReFormat 返回空指针时仅打印日志,没有返回;随后继续调用 x->GetViewShape(),错误路径会发生空指针解引用,告警成立。

修复时应在 ReFormat 失败后立即终止并向上传递失败,不能只记录日志;同时补充格式转换失败回归。后续由责任人安排修复和验证。

likedislike
Nice tryNice try成员
20 天前 将 Nice_try 设为负责人
Nice tryNice try成员
20 天前 关联了pull request:fix nullptrDeref of aclnn_remainder
CANN-robotCANN-robot成员
18 天前 关闭了 issue
CANN-robotCANN-robot成员
18 天前 添加了label:resolved