已合并
fix:fix dangling pointer #683
zhaowenrui创建于 3月6日
fix:fix dangling pointer #683
已合并
共 3 个文件变更+20-9
| @@ -228,7 +228,7 @@ void AicpuModelErrProc::RecordAicoreOpErrLog(const AicpuSqeAdapter::AicpuTaskRep | |||
| 228 | reportInfo.taskId = info.task_id; | 228 | reportInfo.taskId = info.task_id; |
| 229 | reportInfo.modelId = static_cast<uint32_t>(info.model_id); | 229 | reportInfo.modelId = static_cast<uint32_t>(info.model_id); |
| 230 | reportInfo.tsId = tsId; | 230 | reportInfo.tsId = tsId; |
| 231 | - if (ReportErrLog(reportInfo, &aicpuSqeAdapter) != AICPU_SCHEDULE_OK) { | 231 | + if (ReportErrLog(reportInfo, aicpuSqeAdapter) != AICPU_SCHEDULE_OK) { |
| 232 | aicpusd_err("Failed to report AicoreErrLog, offset[%u].", offset); | 232 | aicpusd_err("Failed to report AicoreErrLog, offset[%u].", offset); |
| 233 | SetUnitLogEmpy(tsId, offset); | 233 | SetUnitLogEmpy(tsId, offset); |
| 234 | } | 234 | } |
| @@ -296,18 +296,21 @@ void AicpuModelErrProc::RecordAicpuOpErrLog(const RunContext &taskContext, const | |||
| 296 | return; | 296 | return; |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | -uint32_t AicpuModelErrProc::ReportErrLog(const ErrLogRptInfo &reportInfo, AicpuSqeAdapter *aicpuSqeAdapterPtr) const | 299 | +uint32_t AicpuModelErrProc::ReportErrLog(const ErrLogRptInfo &reportInfo, AicpuSqeAdapter &aicpuSqeAdapterPtr) const |
| 300 | { | 300 | { |
| 301 | aicpusd_info("Begin to report log, tsId[%u], modelId[%u], streamId[%u], taskId[%u], offset[%u].", | 301 | aicpusd_info("Begin to report log, tsId[%u], modelId[%u], streamId[%u], taskId[%u], offset[%u].", |
| 302 | reportInfo.tsId, reportInfo.modelId, reportInfo.streamId, reportInfo.taskId, reportInfo.offset); | 302 | reportInfo.tsId, reportInfo.modelId, reportInfo.streamId, reportInfo.taskId, reportInfo.offset); |
| 303 | AicpuSqeAdapter::ErrMsgRspInfo errMsgRspInfo(reportInfo.offset, reportInfo.errCode, reportInfo.streamId, | 303 | AicpuSqeAdapter::ErrMsgRspInfo errMsgRspInfo(reportInfo.offset, reportInfo.errCode, reportInfo.streamId, |
| 304 | reportInfo.taskId, reportInfo.modelId, reportInfo.tsId); | 304 | reportInfo.taskId, reportInfo.modelId, reportInfo.tsId); |
| 305 | AicpuSqeAdapter aicpuSqeAdapter(FeatureCtrl::GetTsMsgVersion()); | 305 | AicpuSqeAdapter aicpuSqeAdapter(FeatureCtrl::GetTsMsgVersion()); |
| 306 | - if (aicpuSqeAdapterPtr == nullptr) { | 306 | + const int32_t ret = aicpuSqeAdapterPtr.ErrorMsgResponseToTs(errMsgRspInfo); |
| 307 | - aicpuSqeAdapterPtr = &aicpuSqeAdapter; | ||
| 308 | - } | ||
| 309 | - const int32_t ret = aicpuSqeAdapterPtr->ErrorMsgResponseToTs(errMsgRspInfo); | ||
| 310 | aicpusd_info("Finished to send logmsg report information, ret[%d].", ret); | 307 | aicpusd_info("Finished to send logmsg report information, ret[%d].", ret); |
| 311 | return ret; | 308 | return ret; |
| 312 | } | 309 | } |
| 310 | + | ||
| 311 | +uint32_t AicpuModelErrProc::ReportErrLog(const ErrLogRptInfo &reportInfo) const | ||
| 312 | +{ | ||
| 313 | + AicpuSqeAdapter aicpuSqeAdapter(FeatureCtrl::GetTsMsgVersion()); | ||
| 314 | + return ReportErrLog(reportInfo, aicpuSqeAdapter); | ||
| 315 | +} | ||
| 313 | } // namespace AicpuSchedule | 316 | } // namespace AicpuSchedule |
| @@ -138,13 +138,21 @@ namespace AicpuSchedule { | |||
| 138 | */ | 138 | */ |
| 139 | uint32_t AddErrLog(const aicpu::AicpuErrMsgInfo &errLog, const uint32_t tsId, uint32_t &offset); | 139 | uint32_t AddErrLog(const aicpu::AicpuErrMsgInfo &errLog, const uint32_t tsId, uint32_t &offset); |
| 140 | 140 | ||
| 141 | + /** | ||
| 142 | + * @ingroup ReportErrLog | ||
| 143 | + * @brief report an ERR log to TS. | ||
| 144 | + * @param [in] reportInfo : the error info report to TS. AicpuSqeAdapter: aicpu sqe adapter. | ||
| 145 | + * @return AICPU_SCHEDULE_OK: success, other: error code | ||
| 146 | + */ | ||
| 147 | + uint32_t ReportErrLog(const ErrLogRptInfo &reportInfo, AicpuSqeAdapter &aicpuSqeAdapterPtr) const; | ||
| 148 | + | ||
| 141 | /** | 149 | /** |
| 142 | * @ingroup ReportErrLog | 150 | * @ingroup ReportErrLog |
| 143 | * @brief report an ERR log to TS. | 151 | * @brief report an ERR log to TS. |
| 144 | * @param [in] reportInfo : the error info report to TS. | 152 | * @param [in] reportInfo : the error info report to TS. |
| 145 | * @return AICPU_SCHEDULE_OK: success, other: error code | 153 | * @return AICPU_SCHEDULE_OK: success, other: error code |
| 146 | */ | 154 | */ |
| 147 | - uint32_t ReportErrLog(const ErrLogRptInfo &reportInfo, AicpuSqeAdapter *aicpuSqeAdapterPtr = nullptr) const; | 155 | + uint32_t ReportErrLog(const ErrLogRptInfo &reportInfo) const; |
| 148 | private: | 156 | private: |
| 149 | SpinLock lockBuff_; // SpinLock of operate buffBaseAddr_ | 157 | SpinLock lockBuff_; // SpinLock of operate buffBaseAddr_ |
| 150 | uint64_t buffBaseAddr_[ERRLOG_TS_MAXNUM]; // log addr | 158 | uint64_t buffBaseAddr_[ERRLOG_TS_MAXNUM]; // log addr |
| @@ -966,7 +966,7 @@ TEST_F(AICPUScheduleTEST, ProcessHWTSControlEventV1ReportErrLogTest) { | |||
| 966 | info.cmd_type = TS_AICPU_TASK_REPORT; | 966 | info.cmd_type = TS_AICPU_TASK_REPORT; |
| 967 | AicpuSqeAdapter adapter(info, 1U); | 967 | AicpuSqeAdapter adapter(info, 1U); |
| 968 | MOCKER(tsDevSendMsgAsync).stubs().will(invoke(tsDevSendMsgAsyncreporterrlogV1Success)); | 968 | MOCKER(tsDevSendMsgAsync).stubs().will(invoke(tsDevSendMsgAsyncreporterrlogV1Success)); |
| 969 | - const auto ret = AicpuModelErrProc::GetInstance().ReportErrLog(reportInfo, &adapter); | 969 | + const auto ret = AicpuModelErrProc::GetInstance().ReportErrLog(reportInfo, adapter); |
| 970 | EXPECT_EQ(ret, AICPU_SCHEDULE_OK); | 970 | EXPECT_EQ(ret, AICPU_SCHEDULE_OK); |
| 971 | } | 971 | } |
| 972 | 972 | ||
| @@ -975,7 +975,7 @@ TEST_F(AICPUScheduleTEST, ProcessHWTSControlEventV0ReportErrLogTest) { | |||
| 975 | ErrLogRptInfo reportInfo = {}; | 975 | ErrLogRptInfo reportInfo = {}; |
| 976 | AicpuSqeAdapter adapter(info, 0U); | 976 | AicpuSqeAdapter adapter(info, 0U); |
| 977 | MOCKER(tsDevSendMsgAsync).stubs().will(invoke(tsDevSendMsgAsyncModelreporterrlogV0Success)); | 977 | MOCKER(tsDevSendMsgAsync).stubs().will(invoke(tsDevSendMsgAsyncModelreporterrlogV0Success)); |
| 978 | - const auto ret = AicpuModelErrProc::GetInstance().ReportErrLog(reportInfo, &adapter); | 978 | + const auto ret = AicpuModelErrProc::GetInstance().ReportErrLog(reportInfo, adapter); |
| 979 | EXPECT_EQ(ret, AICPU_SCHEDULE_OK); | 979 | EXPECT_EQ(ret, AICPU_SCHEDULE_OK); |
| 980 | } | 980 | } |
| 981 | 981 | ||