FAQ
Hello,

Race detection enabled binaries all sleep for 1 second before exiting.
Why is it so? I have to set GORACE=atexit_sleep_ms=0 to make it run normally.

Rémy.

--

Search Discussions

  • Minux at Jan 27, 2013 at 6:42 pm

    On Mon, Jan 28, 2013 at 2:20 AM, Rémy Oudompheng wrote:

    Race detection enabled binaries all sleep for 1 second before exiting.
    Why is it so? I have to set GORACE=atexit_sleep_ms=0 to make it run
    normally.
    it aims to catch races involving C's atexit().
    however, Go doesn't have atexit() so i think we can apply this patch to
    compiler_rt.

    diff --git a/lib/tsan/rtl/tsan_flags.cc b/lib/tsan/rtl/tsan_flags.cc
    index 88c4bb6..f0bd238 100644
    --- a/lib/tsan/rtl/tsan_flags.cc
    +++ b/lib/tsan/rtl/tsan_flags.cc
    @@ -50,7 +50,7 @@ void InitializeFlags(Flags *f, const char *env) {
    f->suppressions = "";
    f->exitcode = 66;
    f->log_path = "stderr";
    - f->atexit_sleep_ms = 1000;
    + f->atexit_sleep_ms = kGoMode ? 0 : 1000; // no atexit() for Go
    f->verbosity = 0;
    f->profile_memory = "";
    f->flush_memory_ms = 0;

    --
  • Dmitry Vyukov at Jan 30, 2013 at 4:48 pm

    On Sunday, January 27, 2013 10:41:45 PM UTC+4, minux wrote:
    On Mon, Jan 28, 2013 at 2:20 AM, Rémy Oudompheng <remyoud...@gmail.com<javascript:>
    wrote:
    Race detection enabled binaries all sleep for 1 second before exiting.
    Why is it so? I have to set GORACE=atexit_sleep_ms=0 to make it run
    normally.
    it aims to catch races involving C's atexit().
    however, Go doesn't have atexit() so i think we can apply this patch to
    compiler_rt.

    diff --git a/lib/tsan/rtl/tsan_flags.cc b/lib/tsan/rtl/tsan_flags.cc
    index 88c4bb6..f0bd238 100644
    --- a/lib/tsan/rtl/tsan_flags.cc
    +++ b/lib/tsan/rtl/tsan_flags.cc
    @@ -50,7 +50,7 @@ void InitializeFlags(Flags *f, const char *env) {
    f->suppressions = "";
    f->exitcode = 66;
    f->log_path = "stderr";
    - f->atexit_sleep_ms = 1000;
    + f->atexit_sleep_ms = kGoMode ? 0 : 1000; // no atexit() for Go
    f->verbosity = 0;
    f->profile_memory = "";
    f->flush_memory_ms = 0;
    Hi,

    atexit_sleep_ms had proven to be extremely useful in C++ land to catch
    races between background threads and destructors of globals/function static
    objects.
    I don't remember any Go atexit races (but I've seen much less Go races than
    C++ races, though). But the idea that you may have:

    func main() {
    ...
    go backgroundProcess(...)
    ...
    ...
    foo.Shutdown()
    }

    func backgroundProcess(...) {
    for {
    time.Sleep(time.Second)
    foo.DoSomething()
    }
    }

    Here we have a race between foo.DoSomething() and foo.Shutdown(), but it
    unlikely will be found w/o atexit_sleep_ms.

    Can you describe the context in which you need to set atexit_sleep_ms=0?
    The concern is that if we set it to 0, since it only leads to false
    negatives, nobody will ever turn it on.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 27, '13 at 6:20p
activeJan 30, '13 at 4:48p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase