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

Fix stacked borrows violation in get2_unchecked_mut #115

Merged
merged 4 commits into from
Mar 23, 2022
Merged

Fix stacked borrows violation in get2_unchecked_mut #115

merged 4 commits into from
Mar 23, 2022

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Mar 22, 2022

error: Undefined Behavior: trying to reborrow <2754> for Unique permission at alloc1294[0x0], but that tag does not exist in the borrow stack for this location
   --> /Users/taiki/projects/sources/tokio-rs/slab/src/lib.rs:835:16
    |
835 |         match (&mut *ptr1, &mut *ptr2) {
    |                ^^^^^^^^^^
    |                |
    |                trying to reborrow <2754> for Unique permission at alloc1294[0x0], but that tag does not exist in the borrow stack for this location
    |                this error occurs as part of a reborrow at alloc1294[0x0..0x10]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
            
    = note: inside `slab::Slab::<i32>::get2_unchecked_mut` at /Users/taiki/projects/sources/tokio-rs/slab/src/lib.rs:835:16
note: inside `main::_doctest_main_src_lib_rs_820_0` at src/lib.rs:10:33
   --> src/lib.rs:827:33
    |
10  | let (value1, value2) = unsafe { slab.get2_unchecked_mut(key1, key2) };
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `main` at src/lib.rs:14:3
   --> src/lib.rs:831:3
    |
14  | } _doctest_main_src_lib_rs_820_0() }
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error

@taiki-e taiki-e requested a review from Darksonn March 22, 2022 20:08
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
Co-authored-by: Alice Ryhl <alice@ryhl.io>
@taiki-e
Copy link
Member Author

taiki-e commented Mar 22, 2022

@Darksonn Thanks for the review! I applied your suggestions.

@taiki-e taiki-e requested a review from Darksonn March 22, 2022 22:12
@taiki-e taiki-e merged commit 08b1080 into master Mar 23, 2022
@taiki-e taiki-e deleted the miri branch March 23, 2022 19:49
@taiki-e taiki-e mentioned this pull request Mar 27, 2022
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

Successfully merging this pull request may close these issues.

2 participants