Skip to content

runtime/race: detect when program synchronizes with time.Sleep #6689

@dvyukov

Description

@dvyukov
There is a common pattern of "synchronization":

var result ...
go func() {
  ...
  result = ...
}()
time.Sleep(time.Second)  // 1 second should be enough for everyone
if bad(result) {
  complain()
}

C++ ThreadSanitizer prints a useful "As if synchronized via sleep" message
with a stack trace of the sleep:
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc?view=markup

It would be useful to do the same for Go.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions