]> Cypherpunks repositories - gostls13.git/commit
runtime: document special memmove requirements
authorAustin Clements <austin@google.com>
Mon, 6 Jan 2020 16:10:26 +0000 (11:10 -0500)
committerAustin Clements <austin@google.com>
Wed, 22 Jan 2020 18:54:48 +0000 (18:54 +0000)
commit9b5bd30716914a86619c050f0d75c0da4133b257
treee9429c94f4fecb759da0aed31daefa140fb361ed
parent895b7c85addfffe19b66d8ca71c31799d6e55990
runtime: document special memmove requirements

Unlike C's memmove, Go's memmove must be careful to do indivisible
writes of pointer values because it may be racing with the garbage
collector reading the heap.

We've had various bugs related to this over the years (#36101, #13160,
 #12552). Indeed, memmove is a great target for optimization and it's
easy to forget the special requirements of Go's memmove.

The CL documents these (currently unwritten!) requirements. We're also
adding a test that should hopefully keep everyone honest going
forward, though it's hard to be sure we're hitting all cases of
memmove.

Change-Id: I2f59f8d8d6fb42d2f10006b55d605b5efd8ddc24
Reviewed-on: https://go-review.googlesource.com/c/go/+/213418
Reviewed-by: Cherry Zhang <cherryyz@google.com>
13 files changed:
src/runtime/memmove_386.s
src/runtime/memmove_amd64.s
src/runtime/memmove_arm.s
src/runtime/memmove_arm64.s
src/runtime/memmove_mips64x.s
src/runtime/memmove_mipsx.s
src/runtime/memmove_plan9_386.s
src/runtime/memmove_plan9_amd64.s
src/runtime/memmove_ppc64x.s
src/runtime/memmove_riscv64.s
src/runtime/memmove_s390x.s
src/runtime/memmove_wasm.s
src/runtime/stubs.go