-
Notifications
You must be signed in to change notification settings - Fork 5
/
0058-dces.rs
58 lines (47 loc) · 1.26 KB
/
0058-dces.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
53
54
55
56
57
58
/*!
```rudra-poc
[target]
crate = "dces"
version = "0.2.0"
[report]
issue_url = "https://gitlab.redox-os.org/redox-os/dces-rust/-/issues/8"
issue_date = 2020-12-09
rustsec_url = "https://github.com/RustSec/advisory-db/pull/590"
rustsec_id = "RUSTSEC-2020-0139"
[[bugs]]
analyzer = "SendSyncVariance"
bug_class = "SendSyncVariance"
rudra_report_locations = ["src/world.rs:37:1: 42:2"]
```
!*/
#![forbid(unsafe_code)]
use dces::entity::EntityStore;
use dces::prelude::*;
use std::rc::Rc;
struct MyEntityStore {
entity_store_rc: Rc<i32>,
}
impl EntityStore for MyEntityStore {
fn register_entity(&mut self, entity: impl Into<Entity>) {
println!("Thread: {:p}", self.entity_store_rc);
// Races with the Rc in the main thread.
for _ in 0..100_000_000 {
self.entity_store_rc.clone();
}
}
fn remove_entity(&mut self, entity: impl Into<Entity>) {}
}
fn main() {
let rc = Rc::new(42);
let entity_store = MyEntityStore {
entity_store_rc: rc.clone(),
};
let mut world = World::from_stores(entity_store, ComponentStore::default());
std::thread::spawn(move || {
world.create_entity().build();
});
println!("Main: {:p}", rc);
for _ in 0..100_000_000 {
rc.clone();
}
}