Skip to content

Print out both accesses involved in a data race #2205

Closed
@cbeuw

Description

@cbeuw

Currently Miri throws a UB on the access that ultimately causes a data race, which is always the later one. It is not clear where the other access involved in the data race is in the source file.

error: Undefined Behavior: Data race detected between Write on Thread(id = 0, name = "main") and Write on Thread(id = 1) at alloc1 (current vector clock = VClock([5]), conflicting timestamp = VClock([0, 8]))
  --> src/lib.rs:21:18
   |
21 |         unsafe { V = 2 }
   |                  ^^^^^ Data race detected between Write on Thread(id = 0, name = "main") and Write on Thread(id = 1) at alloc1 (current vector clock = VClock([5]), conflicting timestamp = VClock([0, 8]))
   |
   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
           
   = note: inside `tests::data_race` at src/lib.rs:21:18

Both TSan and Go's race detector print out the line numbers of both accesses involved in the data race, we'd like to do the same.

It shouldn't be too hard to implement, we just need to augment VTimestamp with the current Span from MiriEvalContext::cur_span()

pub type VTimestamp = u32;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-data-raceArea: data race detectorA-diagnosticserrors and warnings emitted by miriC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions