fix: generator resume 错误路径归还 native_call_depth 防执行期 GC 永久跳过

This commit is contained in:
2026-08-15 14:53:07 +08:00
parent f2535ffc77
commit 1f8cf449ad
+2
View File
@@ -271,6 +271,7 @@ impl Vm {
unsafe { (*state_ptr).args = args };
if let Err(e) = push_res {
self.restore_inline_state(saved);
self.native_call_depth -= 1;
return Err(e);
}
unsafe { (*state_ptr).phase = GeneratorPhase::Running };
@@ -281,6 +282,7 @@ impl Vm {
if restore_res.is_err() {
// 挂起状态跨 run:sub_modules 已重建,无法恢复(与动态函数同限制)。
self.restore_inline_state(saved);
self.native_call_depth -= 1;
return Err("generator suspended across runs is no longer valid".into());
}
state.phase = GeneratorPhase::Running;