-
Notifications
You must be signed in to change notification settings - Fork 5
/
0046-generator.rs
49 lines (40 loc) · 1.04 KB
/
0046-generator.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
/*!
```rudra-poc
[target]
crate = "generator"
version = "0.6.23"
indexed_version = "0.6.21"
[report]
issue_url = "https://github.com/Xudong-Huang/generator-rs/issues/27"
issue_date = 2020-11-16
rustsec_url = "https://github.com/RustSec/advisory-db/pull/855"
rustsec_id = "RUSTSEC-2020-0151"
[[bugs]]
analyzer = "SendSyncVariance"
bug_class = "SendSyncVariance"
rudra_report_locations = ["src/gen_impl.rs:27:1: 27:55"]
```
!*/
#![forbid(unsafe_code)]
use generator::Gn;
use std::{rc::Rc, thread};
fn main() {
let rc = Rc::new(());
let rc_clone = rc.clone();
let mut generator = Gn::new_scoped(move |_| {
return rc_clone;
});
let child = thread::spawn(move || {
let smuggled_rc = generator.next().unwrap();
println!("RC in thread: {:p}", smuggled_rc);
for _ in 0..1000000000 {
let x = smuggled_rc.clone();
}
});
println!("RC in main: {:p}", rc);
for _ in 0..1000000000 {
let x = rc.clone();
}
child.join().unwrap();
assert_eq!(Rc::strong_count(&rc), 2);
}