Change information
Commit message:
runtime: keep track of secret allocation size
During a naive attempt to test the new runtime/secret package, I tried
wrapping the entire handshake in a secret.Do call. This lead to a panic
because some of the allocator logic had been previously untested.
freeSpecial takes p and size, but they can be misleading. They don't
refer to the pointer and size of the object with the special attached,
but a pointer to the enclosing object and the size of the span element.
The previous code did not take this into account and when passing the
size to memclr would overwrite nearby objects.
Fix by storing the size of the object being cleared inside the special.
Fixes #76865.
Change-Id: Ifae31f1c8d0609a562a37f37c45aec2f369dc6a5
Files:
- M src/runtime/malloc.go
- M src/runtime/malloc_generated.go
- M src/runtime/malloc_stubs.go
- M src/runtime/mheap.go
- M src/runtime/secret.go
- A src/runtime/secret/alloc_test.go
- M src/runtime/secret_nosecret.go
Change size: M
Delta: 7 files changed, 147 insertions(+), 89 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +1 by David Chase, +2 by Michael Knyszek
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI