Skip to content

Threadpool implementation is unsound #369

@Sp00ph

Description

@Sp00ph

The following test case fails with a SIGSEGV, due to a use after drop on a local variable:

#[test]
fn use_after_drop() {
    let mut global = String::new();
    let thread = make_worker_thread();
    {
        let local = String::from("test");
        std::thread::scope(|s| {
            drop(s.spawn_into(
                || {
                    std::thread::sleep(std::time::Duration::from_secs(1));
                    global = local.clone();
                },
                &thread,
            ));
        });
    }
    thread.join();

    assert_eq!(global, "test");
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions