Skip to content

Commit 2a073bf

Browse files
committed
Track location for atomic new/drop
1 parent 93c96d5 commit 2a073bf

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/rt/atomic.rs

+4
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ impl<T: Numeric> Atomic<T> {
313313
state.stores[index].value = T::into_u64(self.0);
314314

315315
if !std::thread::panicking() {
316+
state
317+
.unsync_mut_locations
318+
.track(location!(), &execution.threads);
316319
state.track_unsync_mut(&execution.threads);
317320
}
318321
});
@@ -358,6 +361,7 @@ impl State {
358361
};
359362

360363
// All subsequent accesses must happen-after.
364+
state.unsync_mut_locations.track(location, &threads);
361365
state.track_unsync_mut(threads);
362366

363367
// Store the initial thread

src/rt/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#[macro_use]
2+
mod location;
3+
pub(crate) use self::location::Location;
4+
15
mod access;
26
use self::access::Access;
37

@@ -10,10 +14,6 @@ pub(crate) use self::arc::Arc;
1014
mod atomic;
1115
pub(crate) use self::atomic::{fence, Atomic};
1216

13-
#[macro_use]
14-
mod location;
15-
pub(crate) use self::location::Location;
16-
1717
mod cell;
1818
pub(crate) use self::cell::Cell;
1919

tests/atomic.rs

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ use loom::thread;
66
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
77
use std::sync::Arc;
88

9+
#[test]
10+
fn load_after_new() {
11+
loom::model(|| {
12+
let a = AtomicUsize::new(0);
13+
a.load(Relaxed);
14+
});
15+
}
16+
917
#[test]
1018
#[should_panic]
1119
fn invalid_unsync_load_relaxed() {

0 commit comments

Comments
 (0)