]> Cypherpunks repositories - gostls13.git/commit
time: move runtimeTimer out of Timer struct
authorRuss Cox <rsc@golang.org>
Thu, 29 Feb 2024 23:03:23 +0000 (18:03 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 9 Mar 2024 03:40:04 +0000 (03:40 +0000)
commitbc20704c265be3c5c6696dd703202ecef9b31d4f
tree02327ff2bf5df69209eabbad9330d39080a32912
parent07b4fee5810005357ba64d2934de90dee244f51d
time: move runtimeTimer out of Timer struct

If user code has two timers t1 and t2 and does *t1 = *t2
(or *t1 = Timer{}), it creeps me out that we would be
corrupting the runtime data structures inlined in the
Timer struct. Replace that field with a pointer to the
runtime data structure instead, so that the corruption
cannot happen, even in a badly behaved program.

In fact, remove the struct definition entirely and linkname
a constructor instead. Now the runtime can evolve the struct
however it likes without needing to keep package time in sync.

Also move the workaround logic for #21874 out of
runtime and into package time.

Change-Id: Ia30f7802ee7b3a11f5d8a78dd30fd9c8633dc787
Reviewed-on: https://go-review.googlesource.com/c/go/+/568339
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/export_test.go
src/runtime/mgcscavenge.go
src/runtime/time.go
src/runtime/time_test.go
src/runtime/trace2.go
src/time/internal_test.go
src/time/sleep.go
src/time/tick.go