pub struct GlobalState {
    multi_threaded: Cell<bool>,
    ongoing_action_data_race_free: Cell<bool>,
    vector_clocks: RefCell<IndexVec<VectorIdx, ThreadClockSet>>,
    vector_info: RefCell<IndexVec<VectorIdx, ThreadId>>,
    thread_info: RefCell<IndexVec<ThreadId, ThreadExtraState>>,
    reuse_candidates: RefCell<FxHashSet<VectorIdx>>,
    terminated_threads: RefCell<FxHashMap<ThreadId, VectorIdx>>,
    last_sc_fence: RefCell<VClock>,
    last_sc_write: RefCell<VClock>,
    pub track_outdated_loads: bool,
}
Expand description

Global data-race detection state, contains the currently executing thread as well as the vector-clocks associated with each of the threads.

Fields§

§multi_threaded: Cell<bool>

Set to true once the first additional thread has launched, due to the dependency between before and after a thread launch. Any data-races must be recorded after this so concurrent execution can ignore recording any data-races.

§ongoing_action_data_race_free: Cell<bool>

A flag to mark we are currently performing a data race free action (such as atomic access) to supress the race detector

§vector_clocks: RefCell<IndexVec<VectorIdx, ThreadClockSet>>

Mapping of a vector index to a known set of thread clocks, this is not directly mapping from a thread id since it may refer to multiple threads.

§vector_info: RefCell<IndexVec<VectorIdx, ThreadId>>

Mapping of a given vector index to the current thread that the execution is representing, this may change if a vector index is re-assigned to a new thread.

§thread_info: RefCell<IndexVec<ThreadId, ThreadExtraState>>

The mapping of a given thread to associated thread metadata.

§reuse_candidates: RefCell<FxHashSet<VectorIdx>>

Potential vector indices that could be re-used on thread creation values are inserted here on after the thread has terminated and been joined with, and hence may potentially become free for use as the index for a new thread. Elements in this set may still require the vector index to report data-races, and can only be re-used after all active vector-clocks catch up with the threads timestamp.

§terminated_threads: RefCell<FxHashMap<ThreadId, VectorIdx>>

This contains threads that have terminated, but not yet joined and so cannot become re-use candidates until a join operation occurs. The associated vector index will be moved into re-use candidates after the join operation occurs.

§last_sc_fence: RefCell<VClock>

The timestamp of last SC fence performed by each thread

§last_sc_write: RefCell<VClock>

The timestamp of last SC write performed by each thread

§track_outdated_loads: bool

Track when an outdated (weak memory) load happens.

Implementations§

Create a new global state, setup with just thread-id=0 advanced to timestamp = 1.

Hook on a thread join to update the implicit happens-before relation between the joined thread (the joinee, the thread that someone waited on) and the current thread (the joiner, the thread who was waiting).

On thread termination, the vector-clock may re-used in the future once all remaining thread-clocks catch up with the time index of the terminated thread. This assigns thread termination with a unique index which will be used to join the thread This should be called strictly before any calls to thread_joined.

Attempt to perform a synchronized operation, this will perform no operation if multi-threading is not currently enabled. Otherwise it will increment the clock for the current vector before and after the operation for data-race detection between any happens-before edges the operation may create.

Internal utility to identify a thread stored internally returns the id and the name for better diagnostics.

Acquire a lock, express that the previous call of validate_lock_release must happen before this. As this is an acquire operation, the thread timestamp is not incremented.

Release a lock handle, express that this happens-before any subsequent calls to validate_lock_acquire. For normal locks this should be equivalent to validate_lock_release_shared since an acquire operation should have occurred before, however for futex & condvar operations this is not the case and this operation must be used.

Release a lock handle, express that this happens-before any subsequent calls to validate_lock_acquire as well as any previous calls to this function after any validate_lock_release calls. For normal locks this should be equivalent to validate_lock_release. This function only exists for joining over the set of concurrent readers in a read-write lock and should not be used for anything else.

Load the vector index used by the given thread as well as the set of vector clocks used by the thread.

Load the current vector clock in use and the current set of thread clocks in use for the vector.

Load the current vector clock in use and the current set of thread clocks in use for the vector mutably for modification.

Return the current thread, should be the same as the data-race active thread.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 264 bytes