fix(memhub): __init__ 显式初始化 detection 字段防默认值失效 - TPC 类字段默认值对 CDefine 常量可能不生效,detection_size=垃圾 → malloc(垃圾) 1-byte 记录区 → 扩容 realloc double-free(ASAN 捕获);显式赋值 detection_size/MEMBUDDY_DET_RECORD_SIZE + _det_arena/_det_records/_det_count/_det_cap

This commit is contained in:
TermiNexus committed 2026-08-25 15:43:54 +08:00
1 parent 40f10f6348
commit fe98b5048e
1 file changed
+8
+8
View File
@@ -333,6 +333,14 @@ class MemBuddy(MemManager):
self.base = base
self.size = size
self.detection = detection
# 显式赋值(不能依赖字段默认值——TPC 类字段默认值对 CDefine 常量
# 可能不生效,垃圾 detection_size → malloc(垃圾) 1-byte 记录区 →
# 扩容 realloc double-free,ASAN 已捕获)
self.detection_size = MEMBUDDY_DET_RECORD_SIZE
self._det_arena = None
self._det_records = None
self._det_count = 0
self._det_cap = 0
self.max_order = 0
self.free_lists = None
self.lock_val = 0