Skip to content

test(driver): assert a dropped Proactor releases in-flight ops - #1018

Merged
Berrysoft merged 1 commit into
compio-rs:masterfrom
Xerxes-2:test/driver-drop-inflight
Aug 22, 2026
Merged

Berrysoft merged 1 commit into
compio-rs:masterfrom
Xerxes-2:test/driver-drop-inflight

Conversation

@Xerxes-2

Copy link
Copy Markdown
Member

The old test does not mutate, it always turns green even without the fix

@github-actions github-actions Bot added the package: driver Related to compio-driver label Aug 21, 2026
@Xerxes-2
Xerxes-2 force-pushed the test/driver-drop-inflight branch 3 times, most recently from d7765ea to 5711766 Compare August 21, 2026 13:19
@Berrysoft

Copy link
Copy Markdown
Member

The IOCP Driver doesn't drop all ops on drop because it's really a "proactor". The operations won't be cancelled even if IOCP is dropped, so it's not safe to drop the fd.

@Xerxes-2
Xerxes-2 force-pushed the test/driver-drop-inflight branch from 5711766 to 448f511 Compare August 21, 2026 23:46
@Xerxes-2

Copy link
Copy Markdown
Member Author

Updated to assert leak on Windows

Comment thread compio-driver/tests/op.rs Resolved
`drop_with_inflight_ops` pushed an `Asyncify` op that completes immediately, so
there was never an in-flight op to observe, and the test asserted nothing: it
passed with or without the `Drop for Driver` fix from compio-rs#769, even under ASan.

Push a recv on a bound UDP socket nobody ever sends to, so the op is genuinely
in-flight, assert that `push` returns `Pending`, and then check what the driver
did with the op by looking at the `SharedFd` clone the op owned.

The correct outcome differs per driver, so assert both sides of it. io_uring
closes the ring on drop, which makes the kernel cancel the op, and the poll
driver owns its keys outright, so both must release the op. IOCP is a real
proactor: dropping the port does not cancel a submitted op, so the kernel may
still write into its buffer, and releasing the key or the fd would be a
use-after-free -- there the op must stay leaked.

Verified against mutants: removing `impl Drop for Driver` fails the io_uring
assertion, and taking the non-IOCP branch on Windows fails the IOCP assertion.
@Xerxes-2
Xerxes-2 force-pushed the test/driver-drop-inflight branch from 448f511 to 73021f9 Compare August 22, 2026 00:05

@George-Miao George-Miao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Berrysoft
Berrysoft merged commit 9721017 into compio-rs:master Aug 22, 2026
89 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 22, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants