• Austin Clements's avatar
    runtime: clear tiny alloc cache in mark term, not sweep term · 835c83b4
    Austin Clements authored
    The tiny alloc cache is maintained in a pointer from non-GC'd memory
    (mcache) to heap memory and hence must be handled carefully.
    
    Currently we clear the tiny alloc cache during sweep termination and,
    if it is assigned to a non-nil value during concurrent marking, we
    depend on a write barrier to keep the new value alive. However, while
    the compiler currently always generates this write barrier, we're
    treading on thin ice because write barriers may not happen for writes
    to non-heap memory (e.g., typedmemmove). Without this lucky write
    barrier, the GC may free a current tiny block while it's still
    reachable by the tiny allocator, leading to later memory corruption.
    
    Change this code so that, rather than depending on the write barrier,
    we simply clear the tiny cache during mark termination when we're
    clearing all of the other mcaches. If the current tiny block is
    reachable from regular pointers, it will be retained; if it isn't
    reachable from regular pointers, it may be freed, but that's okay
    because there won't be any pointers in non-GC'd memory to it.
    
    Change-Id: I8230980d8612c35c2997b9705641a1f9f865f879
    Reviewed-on: https://go-review.googlesource.com/16962
    Run-TryBot: Austin Clements <austin@google.com>
    Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    835c83b4
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang.org/x/net/http2/hpack Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...