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

SharedPointer<T, P>: {Send,Sync} should require T: Send + Sync #18

Closed
yvt opened this issue Mar 12, 2023 · 1 comment
Closed

SharedPointer<T, P>: {Send,Sync} should require T: Send + Sync #18

yvt opened this issue Mar 12, 2023 · 1 comment

Comments

@yvt
Copy link
Contributor

yvt commented Mar 12, 2023

The following program should fail to compile, but it doesn't and crashes at runtime:

use std::cell::Cell;

type Arc<T> = archery::SharedPointer<T, archery::ArcK>;

fn main() {
    let cell = Arc::new(Cell::new(None));

    let jhs = [(); 2].map(|()| {
        let cell = Arc::clone(&cell);
        std::thread::spawn(move || loop {
            // concurrent access of a `!Sync` cell from multiple threads
            cell.take();
            cell.set(Some(Box::new(42)));
        })
    });

    for jh in jhs {
        jh.join().unwrap();
    }
}
$ cargo run --release --quiet
free(): unaligned chunk detected in tcache 2
fish: Job 1, 'cargo run --release' terminated by signal SIGABRT (Abort)
@orium
Copy link
Owner

orium commented Mar 14, 2023

Wow. Thanks for finding and fixing this. Merged.

@orium orium closed this as completed Mar 14, 2023
orium added a commit to orium/rpds that referenced this issue Mar 15, 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 a pull request may close this issue.

2 participants