fix: upvalue cell 改独立堆分配消除 GC sweep 后悬垂
upvalue cell 原先分配于 session_epoch bump arena,对象 sweep 替换 arena 后旧 Bump drop,全部闭包 cell 悬垂:后续分配复用其内存导致 upvalue 值 被覆盖(私有字段 brand 检查跨语句误报、release 下可致 SIGSEGV)。 cell 改为 Box::into_raw 独立堆分配并登记进 session_cell_ptrs 追踪表, 与 arena 生命周期解耦:sweep 搬移对象时 cell 指针稳定,只重写 cell.value 中的对象引用;full_reset 统一释放,无 double-free。
This commit is contained in:
@@ -92,6 +92,7 @@ impl Vm {
|
||||
session_object_ptrs: Vec::new(),
|
||||
session_string_ptrs: Vec::new(),
|
||||
session_bigint_ptrs: std::cell::RefCell::new(Vec::new()),
|
||||
session_cell_ptrs: std::cell::RefCell::new(Vec::new()),
|
||||
session_bytes_allocated: 0,
|
||||
string_gc_watermark: gc_threshold,
|
||||
forwarding: std::collections::HashMap::with_hasher(rustc_hash::FxBuildHasher),
|
||||
@@ -193,6 +194,7 @@ impl Vm {
|
||||
session_object_ptrs: Vec::new(),
|
||||
session_string_ptrs: Vec::new(),
|
||||
session_bigint_ptrs: std::cell::RefCell::new(Vec::new()),
|
||||
session_cell_ptrs: std::cell::RefCell::new(Vec::new()),
|
||||
session_bytes_allocated: 0,
|
||||
string_gc_watermark: gc_threshold,
|
||||
forwarding: std::collections::HashMap::with_hasher(rustc_hash::FxBuildHasher),
|
||||
@@ -300,6 +302,7 @@ impl Vm {
|
||||
self.gc_state.session_gc = crate::session_gc::SessionGc::new();
|
||||
self.free_session_string_heap_data();
|
||||
self.free_session_bigint_heap_data();
|
||||
self.gc_state.free_cells();
|
||||
self.symbols.reset();
|
||||
self.root_reg_limit = 0;
|
||||
self.active_reg_limit = 0;
|
||||
|
||||
Reference in New Issue
Block a user