Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about aliasing and thread safety #63

Open
Nugine opened this issue Jan 23, 2021 · 1 comment
Open

Question about aliasing and thread safety #63

Nugine opened this issue Jan 23, 2021 · 1 comment

Comments

@Nugine
Copy link

Nugine commented Jan 23, 2021

SQ, CQ and Registrar contain NonNull<io_uring> which point to the same value.

pub struct SubmissionQueue<'ring> {
ring: NonNull<uring_sys::io_uring>,
_marker: PhantomData<&'ring mut IoUring>,
}

pub struct CompletionQueue<'ring> {
pub(crate) ring: NonNull<uring_sys::io_uring>,
_marker: PhantomData<&'ring mut IoUring>,
}

iou/src/registrar/mod.rs

Lines 47 to 50 in 045f8d4

pub struct Registrar<'ring> {
ring: NonNull<uring_sys::io_uring>,
_marker: PhantomData<&'ring mut IoUring>,
}

NonNull::as_ref and NonNull::as_mut require borrow check.

But if we split (SQ, CQ) into a producer thread and a consumer thread, both of them can access the same value without synchronization and break the borrow rule.

@Nugine
Copy link
Author

Nugine commented Jan 23, 2021

Here is the only line which calls NonNull::as_mut

prepare_sqe(self.ring.as_mut())

It should be self.ring.as_ptr()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant