• James Chacon's avatar
    runtime: prevent racefini from being invoked more than once · 733162fd
    James Chacon authored
    racefini calls __tsan_fini which is C code and at the end of it
    invoked the standard C library exit(3) call. This has undefined
    behavior if invoked more than once. Specifically in C++ programs
    it caused static destructors to run twice. At least on glibc
    impls it also means the at_exit handlers list (where those are
    stored) also free's a list entry when it completes these. So invoking
    twice results in a double free at exit which trips debug memory
    allocation tracking.
    
    Fix all of this by using an atomic as a boolean barrier around
    calls to racefini being invoked > 1 time.
    
    Fixes #15578
    
    Change-Id: I49222aa9b8ded77160931f46434c61a8379570fc
    Reviewed-on: https://go-review.googlesource.com/22882Reviewed-by: 's avatarDmitry Vyukov <dvyukov@google.com>
    Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    733162fd
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...