Skip to content

Remove SIGURG blocking from maybe_grow_with to restore preemptive scheduling on grown stacks#429

Merged
loongs-zhang merged 2 commits into
masterfrom
copilot/fix-signal-mask-restoration
Mar 31, 2026
Merged

Remove SIGURG blocking from maybe_grow_with to restore preemptive scheduling on grown stacks#429
loongs-zhang merged 2 commits into
masterfrom
copilot/fix-signal-mask-restoration

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

maybe_grow_with was blocking SIGURG for the entire duration of corosensei::on_stack(), which completely disables preemptive scheduling while on a grown stack. Any dead loop inside the callback becomes uninterruptible.

  • Removed SIGURG thread_block/thread_set_mask around on_stack() call
  • Simplified OnStackGuard to only handle stack_infos cleanup (still needed for unwind safety)

Before:

let mut sigurg_mask = SigSet::empty();
sigurg_mask.add(Signal::SIGURG);
let old_mask = SigSet::thread_get_mask();
_ = sigurg_mask.thread_block();
// callback runs here with SIGURG blocked — preemption dead
let r = corosensei::on_stack(stack, callback);
// guard restores mask on drop

After:

co.stack_infos_mut().push_back(StackInfo::from(&stack));
let guard = OnStackGuard { stack_infos: co.stack_infos_mut() };
let r = corosensei::on_stack(stack, callback);
drop(guard);

…uling on grown stacks

Agent-Logs-Url: https://github.com/acl-dev/open-coroutine/sessions/20b581e3-30f1-4e74-b014-4d33795a3902

Co-authored-by: loongs-zhang <38336731+loongs-zhang@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix signal mask restoration in OnStackGuard Remove SIGURG blocking from maybe_grow_with to restore preemptive scheduling on grown stacks Mar 31, 2026
Copilot AI requested a review from loongs-zhang March 31, 2026 13:17
@loongs-zhang loongs-zhang reopened this Mar 31, 2026
@loongs-zhang loongs-zhang marked this pull request as ready for review March 31, 2026 13:24
@loongs-zhang loongs-zhang merged commit 0389957 into master Mar 31, 2026
0 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants