Pull Request has been successfully merged by CANN-robot.
(Thank you for KaranocaVe's contribution.)Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/runtime | ✅ 卢煜坤, zhangpengpeng8 (2/2) | ✅ 卢煜坤 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
KaranocaVe, thanks for your pull request. All authors of the commits have signed the CLA. 👍


变更摘要
本 PR 修改 python/pyACL/rt/rt_memory.cpp 中 GetUnionValueFromPyDict 解析 aclrtMallocAttrValue 的逻辑:原实现将 Python 整数直接窄化转换为 moduleId(uint16_t)、deviceId(uint32_t)和 rsv 元素(uint8_t),超出目标字段范围时会静默截断,导致分配属性被无提示地改变;补丁在转换前增加上界检查并对越界值报错,同时要求 rsv 必须是 list 类型。
主要改动
moduleId范围校验: 先取出PyLong_AsUnsignedLong的结果用于PyErr_Occurred检查,再用UINT16_MAX校验后才写入value.moduleId,超范围时抛出PyExc_ValueError。deviceId范围校验: 同样改为先暂存转换结果并以UINT32_MAX为界判断,越界时抛出PyExc_ValueError,避免uint32_t截断。rsv类型校验: 新增PyList_Check(pyRsv)判断,非 list 输入直接以PyExc_TypeError拒绝,不再先调用PyList_Size。rsv元素范围校验: 每个元素先取PyLong_AsUnsignedLong并通过PyErr_Occurred检查,再以UINT8_MAX为界校验后写入value.rsv[i],越界抛出PyExc_ValueError。
🧩 本次 Review 已使用自定义 Skill:




/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


runtime 仓库的结构文档明确说明其为“预留参数。当前固定配置为0”;当前 Device 内存分配实现对 RSV 属性直接跳过,不读取其内容。因此,正常使用 RSV 属性时,其元素截断不会改变当前的内存分配行为。建议rsv 相关校验暂不作为本次合入。


@KaranocaVe 请修改检视意见


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


@KaranocaVe 请修改下检视意见


@KaranocaVe 请修改检视意见


/compile


@weixin_46600764 @ykl999 已按评审意见修改:去掉了 rsv 的校验(PyList_Check、PyErr 检查、UINT8_MAX 检查及临时变量 item),rsv 解析恢复为 master 原样;moduleId(uint16)与 deviceId(uint32)的范围检查保留,PR 正文也同步去掉了 rsv 校验的表述。麻烦复审,谢谢!


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve
/lgtm


/lgtm


PyACL
acl.rt.malloc_with_cfg对moduleId和deviceId的 Python 整数直接窄化转换,超出目标字段范围时静默截断。补丁增加 uint16/uint32 范围检查,避免分配属性被悄然改变。验证
uint16_t、uint32_t;对超范围值没有错误分支。补丁加入范围检查。git apply --check fix.patch通过。关联 Issue: https://gitcode.com/cann/runtime/issues/1376