Skip to content

refactor(driver): handle panicking#853

Merged
George-Miao merged 1 commit intocompio-rs:masterfrom
George-Miao:refactor/driver/spawn_blocking
Apr 13, 2026
Merged

refactor(driver): handle panicking#853
George-Miao merged 1 commit intocompio-rs:masterfrom
George-Miao:refactor/driver/spawn_blocking

Conversation

@George-Miao
Copy link
Copy Markdown
Member

@George-Miao George-Miao commented Apr 10, 2026

Closes #791

Copilot AI review requested due to automatic review settings April 10, 2026 01:12
@George-Miao George-Miao force-pushed the refactor/driver/spawn_blocking branch from 125e9b9 to b1a64aa Compare April 10, 2026 01:13
@George-Miao George-Miao mentioned this pull request Apr 10, 2026
5 tasks
@George-Miao George-Miao force-pushed the refactor/driver/spawn_blocking branch from b1a64aa to 441e9f3 Compare April 10, 2026 01:20
Copy link
Copy Markdown
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 refactors the driver’s blocking-operation execution so panics in the thread pool are caught, converted into an io::Error, and then re-raised (resumed) on the consumer thread when the result is popped—preventing a worker panic from taking down the pool.

Changes:

  • Add panic utilities (catch_unwind_io / resume_unwind_io) to convert panics into io::Result and later resume unwinding.
  • Wrap blocking-operation execution in catch_unwind_io across poll/io_uring/IOCP backends.
  • Update Proactor::pop / pop_with_extra to resume unwinding when a panic-originated error is observed; add a regression test.

Reviewed changes

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

Show a summary per file
File Description
compio-driver/tests/asyncify.rs Adds a test covering panic behavior in Asyncify/thread-pool execution and tweaks polling behavior in the helper.
compio-driver/src/sys/poll/mod.rs Wraps blocking operate() execution in catch_unwind_io before reporting completion.
compio-driver/src/sys/iour/mod.rs Wraps blocking fallback execution in catch_unwind_io before reporting completion.
compio-driver/src/sys/iocp/mod.rs Wraps blocking execution paths in catch_unwind_io before posting/completing results.
compio-driver/src/panic.rs Introduces panic<->io::Result conversion helpers and a wrapper error type.
compio-driver/src/lib.rs Resumes unwinding in pop and pop_with_extra when the completion represents a panic.
compio-driver/src/asyncify.rs Minor style-only change in worker loop body.

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

Comment thread compio-driver/tests/asyncify.rs
Comment thread compio-driver/tests/asyncify.rs
Comment thread compio-driver/tests/asyncify.rs Outdated
Comment thread compio-driver/src/panic.rs
Comment thread compio-driver/src/lib.rs
Comment thread compio-driver/src/lib.rs Outdated
@George-Miao George-Miao force-pushed the refactor/driver/spawn_blocking branch 3 times, most recently from 22830ac to c0b0733 Compare April 10, 2026 03:48
@George-Miao
Copy link
Copy Markdown
Member Author

Don't know why iocp driver is not catching the panic...

@Berrysoft
Copy link
Copy Markdown
Member

See iocp/mod.rs:494. The result is posted to the IOCP, while an error without raw_os_error will fallback to ERROR_BAD_COMMAND (22).

@George-Miao George-Miao force-pushed the refactor/driver/spawn_blocking branch 3 times, most recently from 67993a8 to a87eb05 Compare April 12, 2026 18:09
@George-Miao George-Miao enabled auto-merge April 12, 2026 18:10
@George-Miao George-Miao self-assigned this Apr 12, 2026
@George-Miao George-Miao added package: driver Related to compio-driver refactor Refactoring existing code labels Apr 12, 2026
@George-Miao George-Miao force-pushed the refactor/driver/spawn_blocking branch 5 times, most recently from 415182d to bc35466 Compare April 13, 2026 00:51
@George-Miao George-Miao force-pushed the refactor/driver/spawn_blocking branch from bc35466 to 0e92075 Compare April 13, 2026 00:53
@George-Miao George-Miao requested a review from Berrysoft April 13, 2026 00:59
@George-Miao George-Miao added this pull request to the merge queue Apr 13, 2026
Merged via the queue into compio-rs:master with commit a4defcb Apr 13, 2026
68 checks passed
@George-Miao George-Miao deleted the refactor/driver/spawn_blocking branch April 13, 2026 01:57
@github-actions github-actions Bot mentioned this pull request Apr 13, 2026
This was referenced Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: driver Related to compio-driver refactor Refactoring existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking issue: Refactor runtime

3 participants