fix: store uring buffers in UringInner - #380
Merged
Merged
Conversation
The driver leaked the timeout/eventfd buffers because they were allocated with Box::leak and later dropped with drop_in_place. That only runs in-place destructors and never frees the leaked allocations. Move the buffers into UringInner so the Rc allocation keeps their addresses stable for io_uring, and use the inner fields directly when building SQEs. This removes the manual drop_in_place calls and lets Rust drop the buffers normally when the driver is dropped, avoiding the leak while preserving behavior.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a memory leak in the io_uring driver where timeout and eventfd buffers were allocated with Box::leak() but incorrectly freed using drop_in_place(), which only runs destructors without deallocating the leaked memory.
The fix moves these buffers from pointer fields in IoUringDriver into owned fields within UringInner, leveraging the existing Rc<UnsafeCell<UringInner>> allocation to maintain stable addresses for io_uring operations while ensuring proper cleanup through Rust's standard drop semantics.
Key changes:
- Converted
timespecfrom*mut TimespectoTimespec(owned value inUringInner) - Converted
eventfd_read_dstfrom*mut u8to[u8; 8](owned array inUringInner) - Removed manual
Box::leak()allocations and incorrectdrop_in_place()calls
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix the Windows WSARecvMsg setup by calling size_of::<GUID>() explicitly, which avoids casting a function item into an integer and satisfies -D function-casts-as-integer. Update the cargo-deny workflow to v2 so CVSS 4.0 advisories parse correctly, and refresh deny.toml by removing deprecated keys and mapping unmaintained to the new 'all' policy. This keeps the previous strict behavior while silencing deprecation warnings.
DorianNiemiecSVRJS
pushed a commit
to DorianNiemiecSVRJS/monoio
that referenced
this pull request
Feb 25, 2026
* fix: store uring buffers in UringInner The driver leaked the timeout/eventfd buffers because they were allocated with Box::leak and later dropped with drop_in_place. That only runs in-place destructors and never frees the leaked allocations. Move the buffers into UringInner so the Rc allocation keeps their addresses stable for io_uring, and use the inner fields directly when building SQEs. This removes the manual drop_in_place calls and lets Rust drop the buffers normally when the driver is dropped, avoiding the leak while preserving behavior. * fix: address build and cargo-deny errors Fix the Windows WSARecvMsg setup by calling size_of::<GUID>() explicitly, which avoids casting a function item into an integer and satisfies -D function-casts-as-integer. Update the cargo-deny workflow to v2 so CVSS 4.0 advisories parse correctly, and refresh deny.toml by removing deprecated keys and mapping unmaintained to the new 'all' policy. This keeps the previous strict behavior while silencing deprecation warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The driver leaked the timeout/eventfd buffers because they were allocated with Box::leak and later dropped with drop_in_place. That only runs in-place destructors and never frees the leaked allocations.
Move the buffers into UringInner so the Rc allocation keeps their addresses stable for io_uring, and use the inner fields directly when building SQEs. This removes the manual drop_in_place calls and lets Rust drop the buffers normally when the driver is dropped, avoiding the leak while preserving behavior.
This issue was found when reviewing #376. Thanks @fereidani !