Skip to content

Instantly share code, notes, and snippets.

@glommer
Last active May 3, 2021 19:45
Show Gist options
  • Save glommer/3f1f706660352c0042f0947631b66fec to your computer and use it in GitHub Desktop.
Save glommer/3f1f706660352c0042f0947631b66fec to your computer and use it in GitHub Desktop.
fn scoped_task_unsound() {
let le = LocalExecutor::default();
le.run(async {
{
let msg = &mut "hello";
let scoped = ScopedTask::local(async {
eprintln!("write to invalid address");
*msg = "oh no";
});
std::mem::forget(scoped); // drop() doesn't run, so the task survives.
}
eprintln!("\noff stack");
});
eprintln!("segfault before this");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment