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 alloc_extend #55

Closed
wants to merge 1 commit into from

Conversation

human-0
Copy link

@human-0 human-0 commented Aug 2, 2022

Currently, there is a Stacked Borrows violation in alloc_extend because &mut chunks.current[next_item_index..] calls deref_mut on the Vec. This borrows the entire slice and invalidates the existing references.

use typed_arena::Arena;

fn main() {
    let arena = Arena::new();
    let a = arena.alloc(0);
    arena.alloc_extend([0]);
    *a = 1; // reference invalid
}

@thomcc
Copy link
Owner

thomcc commented Jan 5, 2023

Note that this is for a different miri issue than #54 -- both should be merged.

Ideally this would have a test too.

thomcc added a commit that referenced this pull request Jan 9, 2023
@thomcc thomcc mentioned this pull request Jan 9, 2023
@thomcc thomcc closed this in b92091a Jan 9, 2023
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