在 InferShapeForTransposeQuantBatchMatMul 函数中,batchSplitFactor 在第190行通过 attrs->GetAttrPointer<int32_t>(5) 获取,该方法可能返回 nullptr(同一函数第167-168行对属性0的 GetAttrPointer 返回值做了显式 nullptr 检查,证明 GetAttrPointer 确实可能返回 nullptr)。第216行的 CHECK 宏使用 && 逻辑:batchSplitFactor != nullptr && *batchSplitFactor != VALID_BATCH_SPLIT_FACTOR,当 batchSplitFactor 为 nullptr 时,由于 C++ 短路求值,第一个条件为 false,整个条件为 false,CHECK 宏不触发返回,执行继续到第220行。第220行 SetShapeY 调用中 *batchSplitFactor 直接解引用可能为 nullptr 的指针,导致空指针解引用崩溃。该函数通过 entry_callchain 确认可从程序入口直接到达。
核查1成立:第190行batchSplitFactor由GetAttrPointer获取(可能返回nullptr,第167-168行对属性0的显式nullptr检查证明此点),第216行CHECK使用&&短路求值,当batchSplitFactor为nullptr时条件为false不触发返回,第220行*batchSplitFactor直接解引用构成空指针解引用缺陷。
核查2无有效防护:第216行CHECK逻辑恰好遗漏了nullptr情况。
核查3函数可达:entry_callchain显示为入口函数。
核查4触发可满足:GetAttrPointer返回nullptr是合理场景。
Source(问题源头) matmul/transpose_quant_batch_mat_mul/op_host/transpose_quant_batch_mat_mul_infershape.cpp:190 行 const auto batchSplitFactor = attrs->GetAttrPointer<int32_t>(5) 从属性指针获取 batchSplitFactor(GetAttrPointer 可能返回 nullptr,同函数第168行对属性0做了显式 nullptr 检查证明此点)
Source(问题源头)
matmul/transpose_quant_batch_mat_mul/op_host/transpose_quant_batch_mat_mul_infershape.cpp:190 行 const auto batchSplitFactor = attrs->GetAttrPointer<int32_t>(5) 从属性指针获取 batchSplitFactor(GetAttrPointer 可能返回 nullptr,同函数第168行对属性0做了显式 nullptr 检查证明此点)
Sink(问题爆发点) matmul/transpose_quant_batch_mat_mul/op_host/transpose_quant_batch_mat_mul_infershape.cpp:220 行 SetShapeY(*shapeY, shapeX1Transposed, shapeX2Transposed, *permY, *batchSplitFactor) 直接解引用可能为 nullptr 的 batchSplitFactor(空指针解引用 sink)
Sink(问题爆发点)
matmul/transpose_quant_batch_mat_mul/op_host/transpose_quant_batch_mat_mul_infershape.cpp:220 行 SetShapeY(*shapeY, shapeX1Transposed, shapeX2Transposed, *permY, *batchSplitFactor) 直接解引用可能为 nullptr 的 batchSplitFactor(空指针解引用 sink)
传播路径:
可达调用链1 起点:(entry functions) → 终点:InferShapeForTransposeQuantBatchMatMul 深度:0
(entry functions)
InferShapeForTransposeQuantBatchMatMul
CHECK(batchSplitFactor == nullptr, CUBE_INNER_ERR_REPORT(nameOp, "batchSplitFactor is null."), return ge::GRAPH_FAILED); CHECK(*batchSplitFactor != VALID_BATCH_SPLIT_FACTOR, CUBE_INNER_ERR_REPORT(nameOp, "batchSplitFactor should be 1 ."), return ge::GRAPH_FAILED);
/assign
缺陷信息
缺陷描述
在 InferShapeForTransposeQuantBatchMatMul 函数中,batchSplitFactor 在第190行通过 attrs->GetAttrPointer<int32_t>(5) 获取,该方法可能返回 nullptr(同一函数第167-168行对属性0的 GetAttrPointer 返回值做了显式 nullptr 检查,证明 GetAttrPointer 确实可能返回 nullptr)。第216行的 CHECK 宏使用 && 逻辑:batchSplitFactor != nullptr && *batchSplitFactor != VALID_BATCH_SPLIT_FACTOR,当 batchSplitFactor 为 nullptr 时,由于 C++ 短路求值,第一个条件为 false,整个条件为 false,CHECK 宏不触发返回,执行继续到第220行。第220行 SetShapeY 调用中 *batchSplitFactor 直接解引用可能为 nullptr 的指针,导致空指针解引用崩溃。该函数通过 entry_callchain 确认可从程序入口直接到达。
事实核查
数据流证据
传播路径:
调用链
可达调用链1 起点:
(entry functions)→ 终点:InferShapeForTransposeQuantBatchMatMul深度:0修复建议
CHECK(batchSplitFactor == nullptr, CUBE_INNER_ERR_REPORT(nameOp, "batchSplitFactor is null."), return ge::GRAPH_FAILED); CHECK(*batchSplitFactor != VALID_BATCH_SPLIT_FACTOR, CUBE_INNER_ERR_REPORT(nameOp, "batchSplitFactor should be 1 ."), return ge::GRAPH_FAILED);