Skip to content

Conversation

@Berrysoft
Copy link
Member

Closes #512

Not sure if it is OK.

cc: @Paraworker

@Berrysoft Berrysoft self-assigned this Nov 16, 2025
@Berrysoft Berrysoft added bug Something isn't working package: runtime Related to compio-runtime labels Nov 16, 2025
Copilot finished reviewing on behalf of Berrysoft November 16, 2025 08:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where task queues could be dropped on different threads than where they were created, which could cause panics due to SendWrapper's drop guard. The fix introduces a WeakTaskQueue pattern to ensure the actual TaskQueue is always dropped on its creator thread.

  • Wraps TaskQueue fields in Arc to enable weak references
  • Introduces WeakTaskQueue with weak references and thread tracking for safe cross-thread handling
  • Refactors task scheduling to use WeakTaskQueue in closures that may be dropped on different threads

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
compio-runtime/src/runtime/scheduler/send_wrapper.rs Adds #[allow(dead_code)] to unused get() method
compio-runtime/src/runtime/scheduler/mod.rs Refactors task queue architecture to prevent cross-thread drops by introducing WeakTaskQueue and Arc-wrapping queue components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

George-Miao
George-Miao previously approved these changes Nov 16, 2025
Copy link
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Paraworker
Copy link
Contributor

I’ve opened a PR that uses raw pointers, so we don’t need extra tricks to work around the limitations of Arc/Weak in this scenario.

@Berrysoft
Copy link
Member Author

Also @Paraworker to review if you're free.

Copy link
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Berrysoft
Copy link
Member Author

I think I'm going to merge this one. It'll be complex to reimplement a better async-task but we have to do that in the future.

@Berrysoft Berrysoft merged commit 3956a2c into compio-rs:master Nov 17, 2025
47 checks passed
@Berrysoft Berrysoft deleted the fix/runtime-drop branch November 17, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working package: runtime Related to compio-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wake_cross_thread still randomly crashes

3 participants