mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: add missing write barriers in append's copy of slice data
Found with GODEBUG=wbshadow=1 mode. Eventually that will run automatically, but right now it still detects other missing write barriers. Change-Id: Ic8624401d7c8225a935f719f96f2675c6f5c0d7c Reviewed-on: https://go-review.googlesource.com/2064 Reviewed-by: Rick Hudson <rlh@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
dcec123a49
commit
a73c1cef07
1 changed files with 6 additions and 2 deletions
|
|
@ -81,12 +81,16 @@ func growslice(t *slicetype, old sliceStruct, n int64) sliceStruct {
|
||||||
var p unsafe.Pointer
|
var p unsafe.Pointer
|
||||||
if et.kind&kindNoPointers != 0 {
|
if et.kind&kindNoPointers != 0 {
|
||||||
p = rawmem(capmem)
|
p = rawmem(capmem)
|
||||||
|
memmove(p, old.array, lenmem)
|
||||||
memclr(add(p, lenmem), capmem-lenmem)
|
memclr(add(p, lenmem), capmem-lenmem)
|
||||||
} else {
|
} else {
|
||||||
// Note: can't use rawmem (which avoids zeroing of memory), because then GC can scan unitialized memory
|
// Note: can't use rawmem (which avoids zeroing of memory), because then GC can scan unitialized memory.
|
||||||
|
// TODO(rsc): Use memmove when !needwb().
|
||||||
p = newarray(et, uintptr(newcap))
|
p = newarray(et, uintptr(newcap))
|
||||||
|
for i := 0; i < old.len; i++ {
|
||||||
|
writebarrierfat(et, add(p, uintptr(i)*et.size), add(old.array, uintptr(i)*et.size))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memmove(p, old.array, lenmem)
|
|
||||||
|
|
||||||
return sliceStruct{p, old.len, newcap}
|
return sliceStruct{p, old.len, newcap}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue