Skip to content

Commit dd487c2

Browse files
fix: prevent SIGURG preemption live-lock by hooking write and reordering facade state transitions
Agent-Logs-Url: https://github.com/acl-dev/open-coroutine/sessions/481d5b61-d175-4f75-ade3-a6f0b5511a71 Co-authored-by: loongs-zhang <38336731+loongs-zhang@users.noreply.github.com>
1 parent 7e7f4f5 commit dd487c2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

core/src/scheduler.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ impl<'s> Scheduler<'s> {
227227
co.syscall(val, syscall, SyscallState::Callback)
228228
.expect("change syscall state failed");
229229
}
230+
//协程在系统调用执行期间被信号抢占,直接放回就绪队列
231+
CoroutineState::Syscall(_, _, SyscallState::Executing) => {}
230232
_ => unreachable!("try_resume unexpect CoroutineState"),
231233
}
232234
self.ready.push(co);
@@ -384,6 +386,23 @@ impl<'s> Scheduler<'s> {
384386
}
385387
}
386388
}
389+
// Check for coroutines preempted during syscall execution (SIGURG race).
390+
// These have SyscallState::Executing and no syscall_suspend entry,
391+
// so they would be stuck in the syscall map forever without this.
392+
let executing: Vec<u64> = self
393+
.syscall
394+
.iter()
395+
.filter(|entry| {
396+
matches!(
397+
entry.value().state(),
398+
CoroutineState::Syscall(_, _, SyscallState::Executing)
399+
)
400+
})
401+
.map(|entry| *entry.key())
402+
.collect();
403+
for co_id in executing {
404+
self.try_resume(co_id);
405+
}
387406
Ok(())
388407
}
389408

0 commit comments

Comments
 (0)