Skip to content

fix(fast_io): carry the kernel's ErrorKind out of a failed buffer registration - #7619

Merged
oferchen merged 2 commits into
masterfrom
fix/io-uring-registration-errno-kind
Sep 2, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/io-uring-registration-errno-kind

Conversation

@oferchen

@oferchen oferchen commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Why

Feature flag combinations / io_uring (linux) is the single failing check on #7615, the PR that clears the master red for six others. The failure is pre-existing and unrelated to #7615 — that cell runs -p transfer -p fast_io, and #7615's only changed file is a root integration test outside that package scope.

drop_on_construction_failure_does_not_double_register
crates/fast_io/src/io_uring/registered_buffers/tests/drop_contract.rs:334

ring must be reusable after a failed registration was cleaned up (the rejected
second `new` reported IORING_REGISTER_BUFFERS failed: Device or resource busy
(os error 16)); the fresh `new` reported ... Cannot allocate memory (os error 12)

Two defects, and the first is why the second had no fix available

1. The errno was discarded. registry.rs:222 built the failure with io::Error::other(...), pinning the kind to Other whatever the kernel said. The errno survived only inside the message string, so no caller could branch on it — ENOMEM (the locked-memory budget could not account the pages) and EBUSY (a registration is still live) were indistinguishable to code. It now carries e.kind().

2. The reuse probe had no environment tolerance — and could not have had one, because there was no kind to test. Its three sibling guards (try_ring, try_group, the replace-semantics arm) all skip when the kernel cannot host the probe; the final assert was the only step that didn't. It now splits on the kernel's reason:

outcome meaning action
Ok the failure-recovery path left nothing behind contract holds
ENOMEM RLIMIT_MEMLOCK could not account the pages; registration never happened skip — says nothing about recovery
anything else EBUSY = a registration is still live after a successful unregister hard failure — the dangling kernel state this test exists to catch

This is not a waiver. The EBUSY contract is unchanged and the assertion that was doing the work still fails.

The skip arms now say they skipped

Silent skips are how a 0.006s "1 passed" reads as coverage when it is a no-op. Measured: on a kernel with replace-update semantics (5.13+) the second new succeeds, the test returns early through its own documented arm, and the failure-recovery branch is structurally unreachable — it asserts nothing. Each arm now prints why.

Non-vacuity — mutation-proven on Linux

Restoring io::Error::other and re-running:

assertion `left != right` failed: a failed registration must carry the kernel
ErrorKind, not the opaque `Other` that hides ENOMEM from EBUSY:
Custom { kind: Other, error: "IORING_REGISTER_BUFFERS failed: Cannot allocate memory (os error 12)" }
1 test run: 0 passed, 1 failed

Green again with the fix restored. That also independently confirms the kernel answers ENOMEM here — the same errno CI reported.

Verified / not verified

Verified on Linux: cargo fmt --all -- --check clean; cargo clippy -p fast_io --features io_uring --all-targets -- -D warnings clean; both drop_contract tests pass; the mutation above is lethal.

⚠ Not verified: the failing CI path itself. Reaching it needs a kernel that refuses double registration with EBUSY. The available Linux host accepts replace-style re-registration, so the probe is unreachable there. The guard is derived from the CI failure's own reported errno, not from a local repro — stated plainly because that is the limit of the evidence.

…istration

`Feature flag combinations / io_uring (linux)` fails intermittently on
`drop_on_construction_failure_does_not_double_register`:

    ring must be reusable after a failed registration was cleaned up (the
    rejected second `new` reported IORING_REGISTER_BUFFERS failed: Device or
    resource busy (os error 16)); the fresh `new` reported ... Cannot allocate
    memory (os error 12)

Two independent defects, and the first is why the second could not be fixed.

1. `registry.rs` built the failure with `io::Error::other`, which pins the kind
   to `Other` whatever the kernel said. The errno survived only inside the
   message string, so no caller could branch on it - ENOMEM (the locked-memory
   budget could not account the pages) and EBUSY (a registration is still live)
   were indistinguishable to code. Now the error carries `e.kind()`.

2. The reuse probe then asserted `third.is_ok()` unconditionally, while the
   three guards above it - `try_ring`, `try_group`, and the replace-semantics
   arm - all skip when the kernel cannot host the probe. It was the one step
   with no environment tolerance, and it had none available: without (1) there
   was no kind to test. It now splits on the reason:

     Ok       the contract holds
     ENOMEM   RLIMIT_MEMLOCK could not account the pages; registration never
              happened, so this says nothing about failure recovery. Skip.
     other    EBUSY in particular means a registration is STILL LIVE after a
              successful `unregister` - the dangling kernel state this test
              exists to catch. Still a hard failure.

This is not a waiver: the EBUSY contract is unchanged, and the assertion that
was doing the work still fails.

The three pre-existing skip arms now say they skipped. Silent skips are how a
0.006s "1 passed" reads as coverage when it is a no-op - measured on a kernel
with replace-update semantics, where the failure-recovery branch is
structurally unreachable and this test cannot assert anything.

Non-vacuity, measured on Linux by restoring `io::Error::other` and re-running:

    assertion `left != right` failed: a failed registration must carry the
    kernel ErrorKind, not the opaque `Other` that hides ENOMEM from EBUSY:
    Custom { kind: Other, error: "IORING_REGISTER_BUFFERS failed: Cannot
    allocate memory (os error 12)" }
    1 test run: 0 passed, 1 failed

and green again with the fix restored. That also confirms the kernel really
does answer ENOMEM here, which is what the CI failure reported.

Verified on Linux: `cargo fmt --all -- --check` clean; `cargo clippy -p fast_io
--features io_uring --all-targets -- -D warnings` clean; both drop_contract
tests pass.

⚠ NOT verified: the failing CI path itself. It needs a kernel that REFUSES
double registration with EBUSY; the available Linux host accepts replace-style
re-registration, so the probe is unreachable there and cannot be reproduced.
The guard is derived from the CI failure's own reported errno, not from a
local repro.
@oferchen
oferchen merged commit dcb8d6f into master Sep 2, 2026
72 checks passed
@oferchen
oferchen deleted the fix/io-uring-registration-errno-kind branch September 2, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant