已合并
[Fix] shmem init attr compatibility #39810
pengqihw创建于 7月1日
[Fix] shmem init attr compatibility #39810
已合并
共 1 个文件变更+7-4
| @@ -193,14 +193,17 @@ typedef struct { | |||
| 193 | * with other modules and processes. | 193 | * with other modules and processes. |
| 194 | * - uint64_t local_mem_size: The size of shared memory currently occupied by current pe. | 194 | * - uint64_t local_mem_size: The size of shared memory currently occupied by current pe. |
| 195 | * - aclshmem_init_optional_attr_t option_attr: Optional Parameters. | 195 | * - aclshmem_init_optional_attr_t option_attr: Optional Parameters. |
| 196 | + * - void *comm_args: Parameters required for communication during the bootstrap phase when initializing different flags. | ||
| 197 | + * - uint64_t instance_id: ACLSHMEM instance id, 0 indicates the default instance. | ||
| 196 | */ | 198 | */ |
| 197 | -typedef struct { | 199 | +typedef struct aclshmemx_init_attr_t { |
| 198 | int my_pe; | 200 | int my_pe; |
| 199 | int n_pes; | 201 | int n_pes; |
| 200 | - char ip_port[ACLSHMEM_MAX_IP_PORT_LEN]; | 202 | + char ip_port[ACLSHMEM_MAX_IP_PORT_LEN] = {}; |
| 201 | uint64_t local_mem_size; | 203 | uint64_t local_mem_size; |
| 202 | aclshmem_init_optional_attr_t option_attr = {(1 << 16) + sizeof(aclshmem_init_optional_attr_t), ACLSHMEM_DATA_OP_MTE, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT}; | 204 | aclshmem_init_optional_attr_t option_attr = {(1 << 16) + sizeof(aclshmem_init_optional_attr_t), ACLSHMEM_DATA_OP_MTE, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT}; |
| 203 | - void *comm_args; | 205 | + void *comm_args = nullptr; |
| 206 | + uint64_t instance_id = 0; | ||
| 204 | } aclshmemx_init_attr_t; | 207 | } aclshmemx_init_attr_t; |
| 205 | 208 | ||
| 206 | /** | 209 | /** |
| @@ -219,4 +222,4 @@ typedef int (*shmem_decrypt_handler)(const char *cipherText, size_t cipherTextLe | |||
| 219 | } | 222 | } |
| 220 | 223 | ||
| 221 | 224 | ||
| 222 | -#endif | 225 | +#endif |
🟡 Medium Priority
变更行为:在
aclshemmx_init_attr_t结构体末尾新增了uint64_t instance_id字段。受影响的契约/行为:该结构体定义在公共头文件
shmem_host_def.h中,作为 SDK 对外暴露的初始化参数结构体。新增字段会使sizeof(aclshemmx_init_attr_t)增加 8 字节,改变结构体内存布局。失败模式:
instance_id)编译的二进制调用新版本库中接收/返回此结构体(按值或指针)的函数,库侧将读取调用方未分配的内存区域作为instance_id,产生未定义行为。version字段作为首成员,库侧无法在运行时检测调用方传入的结构体是否包含instance_id字段,使 ABI 断裂无法被优雅处理。触发条件:任何使用旧版头文件编译的二进制与新版本库(或反之)组合运行时。
建议:在发布说明中明确此 ABI 断裂变更;考虑为结构体增加 version 字段或运行时 sizeof 校验机制,使库侧能检测新旧结构体的不兼容组合。