已合并
【PR】: Error Message相关bugfix修复 #2960
guo-yanjun创建于 6月18日
【PR】: Error Message相关bugfix修复 #2960
已合并
共 14 个文件变更+132-68
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | + | ||
| 14 | 15 | ||
| 15 | 16 | ||
| 16 | 17 | ||
| @@ -1026,17 +1027,21 @@ acltdtChannelHandle *acltdtCreateChannelWithCapacity(uint32_t deviceId, const ch | |||
| 1026 | ACL_CHECK_MALLOC_RESULT_REPORT_RET(handle, sizeof(acltdtChannelHandle), nullptr); | 1027 | ACL_CHECK_MALLOC_RESULT_REPORT_RET(handle, sizeof(acltdtChannelHandle), nullptr); |
| 1027 | handle->isTdtProcess = false; | 1028 | handle->isTdtProcess = false; |
| 1028 | acltdtQueueAttr attr{}; | 1029 | acltdtQueueAttr attr{}; |
| 1029 | - auto ret = memcpy_s(attr.name, RT_MQ_MAX_NAME_LEN, name, strlen(name) + 1); | 1030 | + const size_t count = strlen(name) + 1U; |
| 1031 | + auto ret = memcpy_s(attr.name, RT_MQ_MAX_NAME_LEN, name, count); | ||
| 1030 | if (ret != EN_OK) { | 1032 | if (ret != EN_OK) { |
| 1031 | const std::string retCode = std::to_string(ret); | 1033 | const std::string retCode = std::to_string(ret); |
| 1032 | - const std::string extendInfo = "src=name, nameLen=" + std::to_string(strlen(name) + 1) + | 1034 | + std::stringstream ss; |
| 1033 | - ", dst=attr.name, maxLen=" + std::to_string(RT_MQ_MAX_NAME_LEN); | 1035 | + ss << std::hex << "name=0x" << reinterpret_cast<uintptr_t>(name) |
| 1036 | + << ", dest=0x" << reinterpret_cast<uintptr_t>(attr.name) | ||
| 1037 | + << std::dec << ", dest_max=" << RT_MQ_MAX_NAME_LEN << ", count=" << count << "."; | ||
| 1038 | + const std::string extendInfo = ss.str(); | ||
| 1034 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, | 1039 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, |
| 1035 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), | 1040 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), |
| 1036 | std::vector<const char *>({__func__, "memcpy_s", retCode.c_str(), | 1041 | std::vector<const char *>({__func__, "memcpy_s", retCode.c_str(), |
| 1037 | strerror(ret), extendInfo.c_str()})); | 1042 | strerror(ret), extendInfo.c_str()})); |
| 1038 | ACL_LOG_ERROR("[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%d", | 1043 | ACL_LOG_ERROR("[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%d", |
| 1039 | - ret, strlen(name) + 1, RT_MQ_MAX_NAME_LEN); | 1044 | + ret, count, RT_MQ_MAX_NAME_LEN); |
| 1040 | ACL_DELETE_AND_SET_NULL(handle); | 1045 | ACL_DELETE_AND_SET_NULL(handle); |
| 1041 | return nullptr; | 1046 | return nullptr; |
| 1042 | } | 1047 | } |
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | + | ||
| 13 | 14 | ||
| 14 | 15 | ||
| 15 | 16 | ||
| @@ -28,9 +29,11 @@ namespace { | |||
| 28 | const auto ret = memcpy_s(dst, dstLen, src, srcLen); | 29 | const auto ret = memcpy_s(dst, dstLen, src, srcLen); |
| 29 | if (ret != EOK) { | 30 | if (ret != EOK) { |
| 30 | const std::string retVal = std::to_string(ret); | 31 | const std::string retVal = std::to_string(ret); |
| 31 | - const std::string extendInfo = "src=" + std::to_string(reinterpret_cast<uintptr_t>(src)) + | 32 | + std::stringstream ss; |
| 32 | - ", dst=" + std::to_string(reinterpret_cast<uintptr_t>(dst)) + | 33 | + ss << std::hex << "src=0x" << reinterpret_cast<uintptr_t>(src) |
| 33 | - ", dstLen=" + std::to_string(dstLen) + ", srcLen=" + std::to_string(srcLen); | 34 | + << ", dest=0x" << reinterpret_cast<uintptr_t>(dst) |
| 35 | + << std::dec << ", dest_max=" << dstLen << ", count=" << srcLen << "."; | ||
| 36 | + const std::string extendInfo = ss.str(); | ||
| 34 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, | 37 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, |
| 35 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), | 38 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), |
| 36 | std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), | 39 | std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), |
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | + | ||
| 13 | 14 | ||
| 14 | 15 | ||
| 15 | 16 | ||
| @@ -996,9 +997,11 @@ aclError aclsysGetVersionStrImpl(char *pkgName, char *versionStr) | |||
| 996 | 997 | ||
| 997 | errno_t strcpyRet = strcpy_s(versionStr, ACL_PKG_VERSION_MAX_SIZE, verInfo.c_str()); | 998 | errno_t strcpyRet = strcpy_s(versionStr, ACL_PKG_VERSION_MAX_SIZE, verInfo.c_str()); |
| 998 | if (strcpyRet != EOK) { | 999 | if (strcpyRet != EOK) { |
| 999 | - std::string extendInfo = acl::AclErrorLogManager::FormatStr( | 1000 | + std::stringstream ss; |
| 1000 | - "dest=versionStr, destLen=%zu, srcLen=%zu", | 1001 | + ss << std::hex << "src=0x" << reinterpret_cast<uintptr_t>(verInfo.c_str()) |
| 1001 | - static_cast<size_t>(ACL_PKG_VERSION_MAX_SIZE), verInfo.length()); | 1002 | + << ", versionStr=0x" << reinterpret_cast<uintptr_t>(versionStr) |
| 1003 | + << std::dec << ", dest_max=" << static_cast<size_t>(ACL_PKG_VERSION_MAX_SIZE) << "."; | ||
| 1004 | + const std::string extendInfo = ss.str(); | ||
| 1002 | const std::string strcpyRetVal = std::to_string(strcpyRet); | 1005 | const std::string strcpyRetVal = std::to_string(strcpyRet); |
| 1003 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, | 1006 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, |
| 1004 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), | 1007 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), |
| @@ -9,6 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | + | ||
| 12 | 13 | ||
| 13 | 14 | ||
| 14 | 15 | ||
| @@ -39,12 +40,14 @@ static aclError FillAttrValue(const void *const src, const size_t srcLen, void * | |||
| 39 | if (ret != EOK) { | 40 | if (ret != EOK) { |
| 40 | ACL_LOG_ERROR("call memcpy_s failed, result = %d, srcLen = %zu, dstLen = %zu", ret, srcLen, dstLen); | 41 | ACL_LOG_ERROR("call memcpy_s failed, result = %d, srcLen = %zu, dstLen = %zu", ret, srcLen, dstLen); |
| 41 | const std::string retVal = std::to_string(ret); | 42 | const std::string retVal = std::to_string(ret); |
| 42 | - const std::string extendInfo = "src=" + std::to_string(reinterpret_cast<uintptr_t>(src)) + | 43 | + std::stringstream ss; |
| 43 | - ", dst=" + std::to_string(reinterpret_cast<uintptr_t>(dst)) + | 44 | + ss << std::hex << "src=0x" << reinterpret_cast<uintptr_t>(src) |
| 44 | - ", dstLen=" + std::to_string(dstLen) + ", srcLen=" + std::to_string(srcLen); | 45 | + << ", attrValue=0x" << reinterpret_cast<uintptr_t>(dst) |
| 46 | + << std::dec << ", valueLen=" << dstLen << ", count=" << srcLen << "."; | ||
| 47 | + const std::string extendInfo = ss.str(); | ||
| 45 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, | 48 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, |
| 46 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), | 49 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), |
| 47 | - std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), | 50 | + std::vector<const char *>({funcName, "memcpy_s", retVal.c_str(), |
| 48 | strerror(ret), extendInfo.c_str()})); | 51 | strerror(ret), extendInfo.c_str()})); |
| 49 | return ACL_ERROR_FAILURE; | 52 | return ACL_ERROR_FAILURE; |
| 50 | } | 53 | } |
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | + | ||
| 15 | 16 | ||
| 16 | 17 | ||
| 17 | 18 | ||
| @@ -1689,12 +1690,15 @@ aclError aclrtGetBufUserDataImpl(const aclrtMbuf buf, void *dataPtr, size_t size | |||
| 1689 | ACL_REQUIRES_CALL_RTS_OK(rtMbufGetPrivInfo(buf, &tmpDataPtr, &bufSize), rtMbufGetPrivInfo); | 1690 | ACL_REQUIRES_CALL_RTS_OK(rtMbufGetPrivInfo(buf, &tmpDataPtr, &bufSize), rtMbufGetPrivInfo); |
| 1690 | ACL_CHECK_LESS_UINT(size + offset, static_cast<size_t>(bufSize)); | 1691 | ACL_CHECK_LESS_UINT(size + offset, static_cast<size_t>(bufSize)); |
| 1691 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(tmpDataPtr); | 1692 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(tmpDataPtr); |
| 1692 | - const auto ret = memcpy_s(dataPtr, size, (static_cast<uint8_t *>(tmpDataPtr) + offset), size); | 1693 | + const void *const srcAddr = static_cast<uint8_t *>(tmpDataPtr) + offset; |
| 1694 | + const auto ret = memcpy_s(dataPtr, size, srcAddr, size); | ||
| 1693 | if (ret != EOK) { | 1695 | if (ret != EOK) { |
| 1694 | const std::string retVal = std::to_string(ret); | 1696 | const std::string retVal = std::to_string(ret); |
| 1695 | - const std::string extendInfo = "src=" + std::to_string(reinterpret_cast<uintptr_t>(tmpDataPtr)) + | 1697 | + std::stringstream ss; |
| 1696 | - ",dst=" + std::to_string(reinterpret_cast<uintptr_t>(dataPtr)) + | 1698 | + ss << std::hex << "src=0x" << reinterpret_cast<uintptr_t>(srcAddr) |
| 1697 | - ",dstLen=" + std::to_string(size) + ",srcLen=" + std::to_string(size); | 1699 | + << ", dataPtr=0x" << reinterpret_cast<uintptr_t>(dataPtr) |
| 1700 | + << std::dec << ", size=" << size << ", count=" << size << "."; | ||
| 1701 | + const std::string extendInfo = ss.str(); | ||
| 1698 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, | 1702 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, |
| 1699 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), | 1703 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), |
| 1700 | std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), | 1704 | std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), |
| @@ -1728,14 +1732,16 @@ aclError aclrtSetBufUserDataImpl(aclrtMbuf buf, const void *dataPtr, size_t size | |||
| 1728 | ACL_REQUIRES_CALL_RTS_OK(rtMbufGetPrivInfo(buf, &tmpDataPtr, &bufSize), rtMbufGetPrivInfo); | 1732 | ACL_REQUIRES_CALL_RTS_OK(rtMbufGetPrivInfo(buf, &tmpDataPtr, &bufSize), rtMbufGetPrivInfo); |
| 1729 | ACL_CHECK_LESS_UINT(size + offset, static_cast<size_t>(bufSize)); | 1733 | ACL_CHECK_LESS_UINT(size + offset, static_cast<size_t>(bufSize)); |
| 1730 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(tmpDataPtr); | 1734 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(tmpDataPtr); |
| 1731 | - const auto ret = memcpy_s((static_cast<uint8_t *>(tmpDataPtr) + offset), | 1735 | + void *const destAddr = static_cast<uint8_t *>(tmpDataPtr) + offset; |
| 1732 | - (static_cast<size_t>(bufSize) - offset), | 1736 | + const size_t destMax = static_cast<size_t>(bufSize) - offset; |
| 1733 | - dataPtr, size); | 1737 | + const auto ret = memcpy_s(destAddr, destMax, dataPtr, size); |
| 1734 | if (ret != EOK) { | 1738 | if (ret != EOK) { |
| 1735 | const std::string retVal = std::to_string(ret); | 1739 | const std::string retVal = std::to_string(ret); |
| 1736 | - const std::string extendInfo = "src=" + std::to_string(reinterpret_cast<uintptr_t>(dataPtr)) + | 1740 | + std::stringstream ss; |
| 1737 | - ", dst=" + std::to_string(reinterpret_cast<uintptr_t>(tmpDataPtr)) + | 1741 | + ss << std::hex << "dataPtr=0x" << reinterpret_cast<uintptr_t>(dataPtr) |
| 1738 | - ", dstLen=" + std::to_string(bufSize - offset) + ", srcLen=" + std::to_string(size); | 1742 | + << ", dest=0x" << reinterpret_cast<uintptr_t>(destAddr) |
| 1743 | + << std::dec << ", dest_max=" << destMax << ", size=" << size << "."; | ||
| 1744 | + const std::string extendInfo = ss.str(); | ||
| 1739 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, | 1745 | acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG, |
| 1740 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), | 1746 | std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}), |
| 1741 | std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), | 1747 | std::vector<const char *>({__func__, "memcpy_s", retVal.c_str(), |
| @@ -491,17 +491,6 @@ | |||
| 491 | "Solution": "Unbind the stream from the already bound model and then rebind it to the current model." | 491 | "Solution": "Unbind the stream from the already bound model and then rebind it to the current model." |
| 492 | } | 492 | } |
| 493 | }, | 493 | }, |
| 494 | - { | ||
| 495 | - "errClass": "RTS Errors", | ||
| 496 | - "errTitle": "Execution_Error_Load_OP_Kernel", | ||
| 497 | - "ErrCode": "EE1008", | ||
| 498 | - "ErrMessage": "OP kernel loading failed. Reason: %s.", | ||
| 499 | - "Arglist": "reason", | ||
| 500 | - "suggestion": { | ||
| 501 | - "Possible Cause": "N/A", | ||
| 502 | - "Solution": "N/A" | ||
| 503 | - } | ||
| 504 | - }, | ||
| 505 | { | 494 | { |
| 506 | "errClass": "RTS Errors", | 495 | "errClass": "RTS Errors", |
| 507 | "errTitle": "Execution_Error_Model", | 496 | "errTitle": "Execution_Error_Model", |
| @@ -792,7 +781,7 @@ | |||
| 792 | "errClass": "ACL Errors", | 781 | "errClass": "ACL Errors", |
| 793 | "errTitle": "Invalid_Argument", | 782 | "errTitle": "Invalid_Argument", |
| 794 | "ErrCode": "EH0001", | 783 | "ErrCode": "EH0001", |
| 795 | - "ErrMessage": "Value [%s] for [%s] is invalid. Reason: %s.", | 784 | + "ErrMessage": "Value %s for %s is invalid. Reason: %s.", |
| 796 | "Arglist": "value,param,reason", | 785 | "Arglist": "value,param,reason", |
| 797 | "suggestion": { | 786 | "suggestion": { |
| 798 | "Possible Cause": "N/A", | 787 | "Possible Cause": "N/A", |
| @@ -803,7 +792,7 @@ | |||
| 803 | "errClass": "ACL Errors", | 792 | "errClass": "ACL Errors", |
| 804 | "errTitle": "Invalid_Argument_Null_Pointer", | 793 | "errTitle": "Invalid_Argument_Null_Pointer", |
| 805 | "ErrCode": "EH0002", | 794 | "ErrCode": "EH0002", |
| 806 | - "ErrMessage": "Argument [%s] must not be null.", | 795 | + "ErrMessage": "Argument %s must not be null.", |
| 807 | "Arglist": "param", | 796 | "Arglist": "param", |
| 808 | "suggestion": { | 797 | "suggestion": { |
| 809 | "Possible Cause": "N/A", | 798 | "Possible Cause": "N/A", |
| @@ -814,7 +803,7 @@ | |||
| 814 | "errClass": "ACL Errors", | 803 | "errClass": "ACL Errors", |
| 815 | "errTitle": "File_Operation_Error_Invalid_Path", | 804 | "errTitle": "File_Operation_Error_Invalid_Path", |
| 816 | "ErrCode": "EH0003", | 805 | "ErrCode": "EH0003", |
| 817 | - "ErrMessage": "Path [%s] is invalid. Reason: %s.", | 806 | + "ErrMessage": "Path %s is invalid. Reason: %s.", |
| 818 | "Arglist": "path,reason", | 807 | "Arglist": "path,reason", |
| 819 | "suggestion": { | 808 | "suggestion": { |
| 820 | "Possible Cause": "N/A", | 809 | "Possible Cause": "N/A", |
| @@ -825,7 +814,7 @@ | |||
| 825 | "errClass": "ACL Errors", | 814 | "errClass": "ACL Errors", |
| 826 | "errTitle": "File_Operation_Error", | 815 | "errTitle": "File_Operation_Error", |
| 827 | "ErrCode": "EH0004", | 816 | "ErrCode": "EH0004", |
| 828 | - "ErrMessage": "File [%s] is invalid. Reason: %s.", | 817 | + "ErrMessage": "File %s is invalid. Reason: %s.", |
| 829 | "Arglist": "path,reason", | 818 | "Arglist": "path,reason", |
| 830 | "suggestion": { | 819 | "suggestion": { |
| 831 | "Possible Cause": "N/A", | 820 | "Possible Cause": "N/A", |
| @@ -836,7 +825,7 @@ | |||
| 836 | "errClass": "ACL Errors", | 825 | "errClass": "ACL Errors", |
| 837 | "errTitle": "Invalid_Argument", | 826 | "errTitle": "Invalid_Argument", |
| 838 | "ErrCode": "EH0005", | 827 | "ErrCode": "EH0005", |
| 839 | - "ErrMessage": "AIPP argument [%s] is invalid. Reason: %s.", | 828 | + "ErrMessage": "AIPP argument %s is invalid. Reason: %s.", |
| 840 | "Arglist": "param,reason", | 829 | "Arglist": "param,reason", |
| 841 | "suggestion": { | 830 | "suggestion": { |
| 842 | "Possible Cause": "N/A", | 831 | "Possible Cause": "N/A", |
| @@ -909,7 +898,7 @@ | |||
| 909 | "errClass": "ACL Errors", | 898 | "errClass": "ACL Errors", |
| 910 | "errTitle": "Invalid_Argument", | 899 | "errTitle": "Invalid_Argument", |
| 911 | "ErrCode": "EH0012", | 900 | "ErrCode": "EH0012", |
| 912 | - "ErrMessage": "%s failed, Parameter %s is invalid. Reason: %s.", | 901 | + "ErrMessage": "%s failed. Parameter %s is invalid. Reason: %s.", |
| 913 | "Arglist": "func, param, reason", | 902 | "Arglist": "func, param, reason", |
| 914 | "suggestion": { | 903 | "suggestion": { |
| 915 | "Possible Cause": "N/A", | 904 | "Possible Cause": "N/A", |
| @@ -60,11 +60,6 @@ | |||
| 60 | ("id", "reason"), \ | 60 | ("id", "reason"), \ |
| 61 | "Failed to bind stream with ID %s. Reason: %s. ErrorCode=EE1007.\n", \ | 61 | "Failed to bind stream with ID %s. Reason: %s. ErrorCode=EE1007.\n", \ |
| 62 | DLOG_ERROR) \ | 62 | DLOG_ERROR) \ |
| 63 | - /* EE1008 - Execution_Error_Load_OP_Kernel */ \ | ||
| 64 | - X(EE1008, "EE1008", \ | ||
| 65 | - ("reason"), \ | ||
| 66 | - "OP kernel loading failed. Reason: %s. ErrorCode=EE1008.\n", \ | ||
| 67 | - DLOG_ERROR) \ | ||
| 68 | /* EE1009 - Execution_Error_Model */ \ | 63 | /* EE1009 - Execution_Error_Model */ \ |
| 69 | X(EE1009, "EE1009", \ | 64 | X(EE1009, "EE1009", \ |
| 70 | ("id", "reason"), \ | 65 | ("id", "reason"), \ |
| @@ -30,7 +30,6 @@ enum class ErrorCode | |||
| 30 | EE1005, | 30 | EE1005, |
| 31 | EE1006, | 31 | EE1006, |
| 32 | EE1007, | 32 | EE1007, |
| 33 | - EE1008, | ||
| 34 | EE1009, | 33 | EE1009, |
| 35 | EE1010, | 34 | EE1010, |
| 36 | EE1011, | 35 | EE1011, |
| @@ -64,11 +64,11 @@ static const ErrorInfoConfig ERROR_MAP[] = { | |||
| 64 | // {"EE4004", "Failed to enable profiling. %s", NULL, "Do not enable profiling repeatedly.", {"extend_info"}}, | 64 | // {"EE4004", "Failed to enable profiling. %s", NULL, "Do not enable profiling repeatedly.", {"extend_info"}}, |
| 65 | 65 | ||
| 66 | // ACL Errors | 66 | // ACL Errors |
| 67 | - {"EH0001", "Value [%s] for [%s] is invalid. Reason: %s.", NULL, NULL, {"value", "param", "reason"}}, | 67 | + {"EH0001", "Value %s for %s is invalid. Reason: %s.", NULL, NULL, {"value", "param", "reason"}}, |
| 68 | - {"EH0002", "Argument [%s] must not be NULL.", NULL, "Try again with a correct pointer argument.", {"param"}}, | 68 | + {"EH0002", "Argument %s must not be NULL.", NULL, "Try again with a correct pointer argument.", {"param"}}, |
| 69 | - {"EH0003", "Path [%s] is invalid. Reason: %s.", NULL, NULL, {"path", "reason"}}, | 69 | + {"EH0003", "Path %s is invalid. Reason: %s.", NULL, NULL, {"path", "reason"}}, |
| 70 | - // {"EH0004", "File [%s] is invalid. Reason: %s.", NULL, NULL, {"path", "reason"}}, //主线没用到 | 70 | + // {"EH0004", "File %s is invalid. Reason: %s.", NULL, NULL, {"path", "reason"}}, //主线没用到 |
| 71 | - // {"EH0005", "AIPP argument [%s] is invalid. Reason: %s.", NULL, NULL, {"param", "reason"}}, // AIPP | 71 | + // {"EH0005", "AIPP argument %s is invalid. Reason: %s.", NULL, NULL, {"param", "reason"}}, // AIPP |
| 72 | // {"EH0006", "%s is not supported. Reason: %s.", NULL, NULL, {"feature", "reason"}}, // DVPP跟TDT | 72 | // {"EH0006", "%s is not supported. Reason: %s.", NULL, NULL, {"feature", "reason"}}, // DVPP跟TDT |
| 73 | 73 | ||
| 74 | // Profiling Errors | 74 | // Profiling Errors |
| @@ -175,12 +175,12 @@ static int SubString(const char *str, const char *sub) | |||
| 175 | 175 | ||
| 176 | /* 函数名:FormatString | 176 | /* 函数名:FormatString |
| 177 | 函数功能:格式化错误模板信息,如 | 177 | 函数功能:格式化错误模板信息,如 |
| 178 | - FormatString({"value", "param", "reason"}, "Value [%s] for [%s] is invalid. Reason: %s.", | 178 | + FormatString({"value", "param", "reason"}, "Value %s for %s is invalid. Reason: %s.", |
| 179 | {"value", "param", "reason"}, {"25", "x", "The value is too small"}, 3); | 179 | {"value", "param", "reason"}, {"25", "x", "The value is too small"}, 3); |
| 180 | - 返回"Value [25] for [x] is invalid. Reason: The value is too small. | 180 | + 返回"Value 25 for x is invalid. Reason: The value is too small. |
| 181 | 输入: | 181 | 输入: |
| 182 | tmplArgList : 模板参数列表,如{"value", "param", "reason"} | 182 | tmplArgList : 模板参数列表,如{"value", "param", "reason"} |
| 183 | - tmplErrorMsg : 模板errMsg, 如"Value [%s] for [%s] is invalid. Reason: %s." | 183 | + tmplErrorMsg : 模板errMsg, 如"Value %s for %s is invalid. Reason: %s." |
| 184 | args : 用户传入的参数列表, {"value", "param", "reason", "..."} | 184 | args : 用户传入的参数列表, {"value", "param", "reason", "..."} |
| 185 | argValues : 用户传入的参数值列表, {"5", "x", "x is invalid", "..."} | 185 | argValues : 用户传入的参数值列表, {"5", "x", "x is invalid", "..."} |
| 186 | argsNum :用户传入的参数值或者参数列表长度, sizeof(args) / sizeof(char*) | 186 | argsNum :用户传入的参数值或者参数列表长度, sizeof(args) / sizeof(char*) |
| @@ -1088,6 +1088,30 @@ TEST_F(UTEST_ACL_Common, aclsysGetVersionStr_InvalidFormat_Fail) | |||
| 1088 | MM_SYS_UNSET_ENV(MM_ENV_ASCEND_HOME_PATH, mmRet); | 1088 | MM_SYS_UNSET_ENV(MM_ENV_ASCEND_HOME_PATH, mmRet); |
| 1089 | } | 1089 | } |
| 1090 | 1090 | ||
| 1091 | +TEST_F(UTEST_ACL_Common, aclsysGetVersionStr_CopyVersionFailed) | ||
| 1092 | +{ | ||
| 1093 | + std::string mockAscendHome = utTestBasePath + "/Ascend"; | ||
| 1094 | + std::string infoPath = mockAscendHome + "/share/info/runtime/version.info"; | ||
| 1095 | + std::string longVersion(ACL_PKG_VERSION_MAX_SIZE, '1'); | ||
| 1096 | + | ||
| 1097 | + writeToFile(infoPath, "Version=" + longVersion); | ||
| 1098 | + | ||
| 1099 | + int32_t mmRet = 0; | ||
| 1100 | + MM_SYS_SET_ENV(MM_ENV_ASCEND_HOME_PATH, mockAscendHome.c_str(), 1, mmRet); | ||
| 1101 | + (void)mmRet; | ||
| 1102 | + | ||
| 1103 | + char pkgName[] = "runtime"; | ||
| 1104 | + char verStr[ACL_PKG_VERSION_MAX_SIZE] = {0}; | ||
| 1105 | + | ||
| 1106 | + aclError ret = aclsysGetVersionStr(pkgName, verStr); | ||
| 1107 | + | ||
| 1108 | + EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 1109 | + EXPECT_EQ(verStr[0], '\0'); | ||
| 1110 | + | ||
| 1111 | + system(("rm -rf " + mockAscendHome).c_str()); | ||
| 1112 | + MM_SYS_UNSET_ENV(MM_ENV_ASCEND_HOME_PATH, mmRet); | ||
| 1113 | +} | ||
| 1114 | + | ||
| 1091 | TEST_F(UTEST_ACL_Common, aclsysGetVersionNum_InvalidFormat_Fail) | 1115 | TEST_F(UTEST_ACL_Common, aclsysGetVersionNum_InvalidFormat_Fail) |
| 1092 | { | 1116 | { |
| 1093 | std::string mockAscendHome = utTestBasePath + "/Ascend"; | 1117 | std::string mockAscendHome = utTestBasePath + "/Ascend"; |
| @@ -2267,6 +2267,23 @@ TEST_F(UTEST_ACL_Runtime, aclrtGetGroupInfoDetail_Fail_ValueLenTooSmall) | |||
| 2267 | EXPECT_EQ(aclrtDestroyGroupInfo(groupInfo), ACL_SUCCESS); | 2267 | EXPECT_EQ(aclrtDestroyGroupInfo(groupInfo), ACL_SUCCESS); |
| 2268 | } | 2268 | } |
| 2269 | 2269 | ||
| 2270 | +TEST_F(UTEST_ACL_Runtime, aclrtGetGroupInfoDetail_Fail_MemcpySecurecRange) | ||
| 2271 | +{ | ||
| 2272 | + EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtGetGroupCount(_)) | ||
| 2273 | + .WillRepeatedly(Return(RT_ERROR_NONE)); | ||
| 2274 | + | ||
| 2275 | + aclrtGroupInfo *groupInfo = aclrtCreateGroupInfo(); | ||
| 2276 | + uint32_t value = 0U; | ||
| 2277 | + size_t paramRetSize = 0U; | ||
| 2278 | + const size_t invalidValueLen = 0x80000000UL; | ||
| 2279 | + | ||
| 2280 | + EXPECT_EQ(aclrtGetGroupInfoDetail(groupInfo, 0, ACL_GROUP_AICORE_INT, | ||
| 2281 | + static_cast<void *>(&value), invalidValueLen, ¶mRetSize), ACL_ERROR_FAILURE); | ||
| 2282 | + EXPECT_EQ(paramRetSize, 0U); | ||
| 2283 | + | ||
| 2284 | + EXPECT_EQ(aclrtDestroyGroupInfo(groupInfo), ACL_SUCCESS); | ||
| 2285 | +} | ||
| 2286 | + | ||
| 2270 | TEST_F(UTEST_ACL_Runtime, aclrtGetAllGroupInfoTest) | 2287 | TEST_F(UTEST_ACL_Runtime, aclrtGetAllGroupInfoTest) |
| 2271 | { | 2288 | { |
| 2272 | aclrtGroupInfo *groupInfo = aclrtCreateGroupInfo(); | 2289 | aclrtGroupInfo *groupInfo = aclrtCreateGroupInfo(); |
| @@ -6224,6 +6241,32 @@ TEST_F(UTEST_ACL_Runtime, aclrtSetBufUserData_failed_with_size_offset_exceed_max | |||
| 6224 | EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM); | 6241 | EXPECT_EQ(ret, ACL_ERROR_INVALID_PARAM); |
| 6225 | } | 6242 | } |
| 6226 | 6243 | ||
| 6244 | +TEST_F(UTEST_ACL_Runtime, aclrtGetBufUserData_failed_when_memcpy_returns_error) | ||
| 6245 | +{ | ||
| 6246 | + char privateData[96] = {0}; | ||
| 6247 | + char data[1] = {0}; | ||
| 6248 | + aclrtMbuf mbuf = reinterpret_cast<aclrtMbuf>(privateData); | ||
| 6249 | + EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMbufGetPrivInfo(_, _, _)) | ||
| 6250 | + .WillOnce(DoAll(SetArgPointee<1>(privateData), SetArgPointee<2>(sizeof(privateData)), | ||
| 6251 | + Return(RT_ERROR_NONE))); | ||
| 6252 | + | ||
| 6253 | + auto ret = aclrtGetBufUserData(mbuf, data, 0U, 0U); | ||
| 6254 | + EXPECT_EQ(ret, ACL_ERROR_FAILURE); | ||
| 6255 | +} | ||
| 6256 | + | ||
| 6257 | +TEST_F(UTEST_ACL_Runtime, aclrtSetBufUserData_failed_when_memcpy_returns_error) | ||
| 6258 | +{ | ||
| 6259 | + char privateData[96] = {0}; | ||
| 6260 | + char data[1] = {0}; | ||
| 6261 | + aclrtMbuf mbuf = reinterpret_cast<aclrtMbuf>(privateData); | ||
| 6262 | + EXPECT_CALL(MockFunctionTest::aclStubInstance(), rtMbufGetPrivInfo(_, _, _)) | ||
| 6263 | + .WillOnce(DoAll(SetArgPointee<1>(privateData), SetArgPointee<2>(sizeof(privateData)), | ||
| 6264 | + Return(RT_ERROR_NONE))); | ||
| 6265 | + | ||
| 6266 | + auto ret = aclrtSetBufUserData(mbuf, data, 0U, sizeof(privateData)); | ||
| 6267 | + EXPECT_EQ(ret, ACL_ERROR_FAILURE); | ||
🔵 Low Priority 在 与 GetBuf 测试同理, 触发条件:同 GetBuf 测试,在 建议:使用 mock 控制 memcpy_s 返回值,或改用 count > destMax > 0 的参数组合来可靠触发 memcpy_s 错误;同时在测试注释中说明当前 securec 对 destMax=0 的处理行为。 ![]() ![]() 不准确? | |||
| 6268 | +} | ||
| 6269 | + | ||
| 6227 | TEST_F(UTEST_ACL_Runtime, aclrtBinaryLoadFromData_failed_with_invalid_args) | 6270 | TEST_F(UTEST_ACL_Runtime, aclrtBinaryLoadFromData_failed_with_invalid_args) |
| 6228 | { | 6271 | { |
| 6229 | void *data = (void*)0x01; | 6272 | void *data = (void*)0x01; |
| @@ -643,7 +643,7 @@ TEST_F(AclRtTest, hostfunc_aclrtProcessHostFuncTest) { | |||
| 643 | TEST_F(AclRtTest, acl_GetRecentErrMsg) { | 643 | TEST_F(AclRtTest, acl_GetRecentErrMsg) { |
| 644 | REPORT_INPUT_ERROR(INVALID_NULL_POINTER_MSG, ARRAY(const_cast<char *>("param")), ARRAY(const_cast<char *>("datatest"))); | 644 | REPORT_INPUT_ERROR(INVALID_NULL_POINTER_MSG, ARRAY(const_cast<char *>("param")), ARRAY(const_cast<char *>("datatest"))); |
| 645 | const char *message = aclGetRecentErrMsg(); | 645 | const char *message = aclGetRecentErrMsg(); |
| 646 | - ASSERT_STREQ(message, "EH0002: Argument [datatest] must not be NULL.\r\n" | 646 | + ASSERT_STREQ(message, "EH0002: Argument datatest must not be NULL.\r\n" |
| 647 | " Solution: Try again with a correct pointer argument.\r\n"); | 647 | " Solution: Try again with a correct pointer argument.\r\n"); |
| 648 | message = aclGetRecentErrMsg(); | 648 | message = aclGetRecentErrMsg(); |
| 649 | ASSERT_STREQ(message, NULL); | 649 | ASSERT_STREQ(message, NULL); |
| @@ -82,9 +82,6 @@ TEST_F(RtErrorCodeTest, PrintErrMsgToLog) | |||
| 82 | std::vector<std::string> values5 = {"10", "repeat bind"}; | 82 | std::vector<std::string> values5 = {"10", "repeat bind"}; |
| 83 | PrintErrMsgToLog(ErrorCode::EE1007, "file", 1000, "func", values5); | 83 | PrintErrMsgToLog(ErrorCode::EE1007, "file", 1000, "func", values5); |
| 84 | 84 | ||
| 85 | - std::vector<std::string> values6 = {"section invalid"}; | ||
| 86 | - PrintErrMsgToLog(ErrorCode::EE1008, "file", 1000, "func", values6); | ||
| 87 | - | ||
| 88 | std::vector<std::string> values7 = {"10", "model invalid"}; | 85 | std::vector<std::string> values7 = {"10", "model invalid"}; |
| 89 | PrintErrMsgToLog(ErrorCode::EE1009, "file", 1000, "func", values7); | 86 | PrintErrMsgToLog(ErrorCode::EE1009, "file", 1000, "func", values7); |
| 90 | 87 | ||
| @@ -145,7 +142,6 @@ TEST_F(RtErrorCodeTest, RePortErrCode) | |||
| 145 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1005, "rtMemCpy"); | 142 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1005, "rtMemCpy"); |
| 146 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1006, "rtMemCpy", "d2d"); | 143 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1006, "rtMemCpy", "d2d"); |
| 147 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1007, "10", "repeat bind"); | 144 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1007, "10", "repeat bind"); |
| 148 | - RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1008, "malloc", "section invalid"); | ||
| 149 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1009, "10", "model invalid"); | 145 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1009, "10", "model invalid"); |
| 150 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1010, "rtModelExecute", "stream"); | 146 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1010, "rtModelExecute", "stream"); |
| 151 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1011, "rtMemCpy", "0", "size", "size is not 0"); | 147 | RT_LOG_OUTER_MSG_IMPL(ErrorCode::EE1011, "rtMemCpy", "0", "size", "size is not 0"); |
| @@ -179,8 +175,6 @@ TEST_F(RtErrorCodeTest, CheckErrCodeParams) | |||
| 179 | EXPECT_EQ(names, (std::vector<std::string>{"func", "type"})); | 175 | EXPECT_EQ(names, (std::vector<std::string>{"func", "type"})); |
| 180 | names = GetParamNames(ErrorCode::EE1007); | 176 | names = GetParamNames(ErrorCode::EE1007); |
| 181 | EXPECT_EQ(names, (std::vector<std::string>{"id", "reason"})); | 177 | EXPECT_EQ(names, (std::vector<std::string>{"id", "reason"})); |
| 182 | - names = GetParamNames(ErrorCode::EE1008); | ||
| 183 | - EXPECT_EQ(names, (std::vector<std::string>{"reason"})); | ||
| 184 | names = GetParamNames(ErrorCode::EE1009); | 178 | names = GetParamNames(ErrorCode::EE1009); |
| 185 | EXPECT_EQ(names, (std::vector<std::string>{"id", "reason"})); | 179 | EXPECT_EQ(names, (std::vector<std::string>{"id", "reason"})); |
| 186 | names = GetParamNames(ErrorCode::EE1010); | 180 | names = GetParamNames(ErrorCode::EE1010); |
| @@ -230,7 +224,7 @@ TEST_F(RtErrorCodeTest, ErrorCodeTableParamCountMatchesMessageFormat) | |||
| 230 | std::vector<CodeInfo> allCodes = { | 224 | std::vector<CodeInfo> allCodes = { |
| 231 | {ErrorCode::EE1001, 1}, {ErrorCode::EE1002, 1}, {ErrorCode::EE1003, 4}, | 225 | {ErrorCode::EE1001, 1}, {ErrorCode::EE1002, 1}, {ErrorCode::EE1003, 4}, |
| 232 | {ErrorCode::EE1004, 2}, {ErrorCode::EE1005, 1}, {ErrorCode::EE1006, 2}, | 226 | {ErrorCode::EE1004, 2}, {ErrorCode::EE1005, 1}, {ErrorCode::EE1006, 2}, |
| 233 | - {ErrorCode::EE1007, 2}, {ErrorCode::EE1008, 1}, {ErrorCode::EE1009, 2}, | 227 | + {ErrorCode::EE1007, 2}, {ErrorCode::EE1009, 2}, |
| 234 | {ErrorCode::EE1010, 2}, {ErrorCode::EE1011, 4}, {ErrorCode::EE1012, 4}, | 228 | {ErrorCode::EE1010, 2}, {ErrorCode::EE1011, 4}, {ErrorCode::EE1012, 4}, |
| 235 | {ErrorCode::EE1013, 1}, {ErrorCode::EE1014, 1}, {ErrorCode::EE1015, 2}, | 229 | {ErrorCode::EE1013, 1}, {ErrorCode::EE1014, 1}, {ErrorCode::EE1015, 2}, |
| 236 | {ErrorCode::EE1016, 2}, {ErrorCode::EE1017, 3}, {ErrorCode::EE1018, 2}, | 230 | {ErrorCode::EE1016, 2}, {ErrorCode::EE1017, 3}, {ErrorCode::EE1018, 2}, |
| @@ -46,10 +46,10 @@ TEST_F(UtestErrManagerTest, ReportErrMessage) { | |||
| 46 | // 外部错误码正常上报,用户传入arglist比模板多一个参数, "reason"模板argList没有 | 46 | // 外部错误码正常上报,用户传入arglist比模板多一个参数, "reason"模板argList没有 |
| 47 | REPORT_INPUT_ERROR("EH0003", ARRAY("path", "reason", "value"), ARRAY("./a.text", "cannot find", "100")); | 47 | REPORT_INPUT_ERROR("EH0003", ARRAY("path", "reason", "value"), ARRAY("./a.text", "cannot find", "100")); |
| 48 | char* errmsg = GetErrorMessage(); | 48 | char* errmsg = GetErrorMessage(); |
| 49 | - ASSERT_STREQ(errmsg, "EH0001: Value [25] for [x] is invalid. Reason: The value is too small.\r\n" | 49 | + ASSERT_STREQ(errmsg, "EH0001: Value 25 for x is invalid. Reason: The value is too small.\r\n" |
| 50 | " TraceBack (most recent call last):\r\n" | 50 | " TraceBack (most recent call last):\r\n" |
| 51 | - " Argument [ll] must not be NULL.\r\n" | 51 | + " Argument ll must not be NULL.\r\n" |
| 52 | - " Path [./a.text] is invalid. Reason: cannot find.\r\n"); | 52 | + " Path ./a.text is invalid. Reason: cannot find.\r\n"); |
| 53 | 53 | ||
| 54 | REPORT_INPUT_ERROR("EK0201", ARRAY("buf_size"), ARRAY("100")); | 54 | REPORT_INPUT_ERROR("EK0201", ARRAY("buf_size"), ARRAY("100")); |
| 55 | errmsg = GetErrorMessage(); | 55 | errmsg = GetErrorMessage(); |
| @@ -87,8 +87,8 @@ TEST_F(UtestErrManagerTest, GetErrorMessage) { | |||
| 87 | " TraceBack (most recent call last):\r\n" | 87 | " TraceBack (most recent call last):\r\n" |
| 88 | " Param input.size() < minsize, check invalid\r\n" | 88 | " Param input.size() < minsize, check invalid\r\n" |
| 89 | " This is an inner error!\r\n" | 89 | " This is an inner error!\r\n" |
| 90 | - " Value [25] for [x] is invalid. Reason: The value is too small.\r\n" | 90 | + " Value 25 for x is invalid. Reason: The value is too small.\r\n" |
| 91 | - " Argument [ll] must not be NULL.\r\n"); | 91 | + " Argument ll must not be NULL.\r\n"); |
| 92 | char* errmsg3 = GetErrorMessage(); | 92 | char* errmsg3 = GetErrorMessage(); |
| 93 | ASSERT_STREQ(errmsg3, NULL); | 93 | ASSERT_STREQ(errmsg3, NULL); |
| 94 | } | 94 | } |


🔵 Low Priority
在
aclrtGetBufUserDataImpl(memory.cpp:1694)中,当size=0时调用memcpy_s(dataPtr, 0, srcAddr, 0),即 destMax 和 count 均为 0。新增测试aclrtGetBufUserData_failed_when_memcpy_returns_error(acl_runtime_unittest.cpp:6244)通过传入size=0U触发此路径,并期望返回ACL_ERROR_FAILURE。然而,C11 Annex K 规定当
count=0时memcpy_s应返回 0(EOK),无需执行拷贝。部分实现(如某些版本的 securec)可能对destMax=0进行约束检查并返回错误。该测试的正确性依赖于具体memcpy_s实现的行为,不具备跨平台可移植性。如果memcpy_s实现返回 EOK,此测试将失败。触发条件:在
memcpy_s(dest, 0, src, 0)返回 EOK 而非错误的平台上运行此测试。建议:使用 mock 控制 memcpy_s 返回值,或改用 count > destMax > 0 的参数组合来可靠触发 memcpy_s 错误;同时在测试注释中说明当前 securec 对 destMax=0 的处理行为。