-
Notifications
You must be signed in to change notification settings - Fork 5
/
0048-ticketed_lock.rs
52 lines (42 loc) · 1.08 KB
/
0048-ticketed_lock.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*!
```rudra-poc
[target]
crate = "ticketed_lock"
version = "0.2.0"
[[target.peer]]
crate = "futures"
version = "0.1.14"
[report]
issue_url = "https://github.com/kvark/ticketed_lock/issues/7"
issue_date = 2020-11-17
rustsec_url = "https://github.com/RustSec/advisory-db/pull/678"
rustsec_id = "RUSTSEC-2020-0119"
[[bugs]]
analyzer = "SendSyncVariance"
bug_class = "SendSyncVariance"
bug_count = 2
rudra_report_locations = ["src/lib.rs:53:1: 53:41", "src/lib.rs:115:1: 115:42"]
```
!*/
#![forbid(unsafe_code)]
use ticketed_lock::TicketedLock;
use futures::Future;
use std::{rc::Rc, thread};
fn main() {
let rc = Rc::new(());
let rc_clone = rc.clone();
let mut lock = TicketedLock::new(rc_clone);
let read_ticket = lock.read();
thread::spawn(move || {
let smuggled_rc = read_ticket.wait().unwrap();
println!("Thread: {:p}", *smuggled_rc);
// Race the refcount with the main thread.
for _ in 0..100_000_000 {
smuggled_rc.clone();
}
});
println!("Main: {:p}", rc);
for _ in 0..100_000_000 {
rc.clone();
}
}