]> Cypherpunks repositories - gostls13.git/commit
[dev.boringcrypto] crypto/internal/boring: fix finalizer-induced crashes
authorRuss Cox <rsc@golang.org>
Wed, 20 Sep 2017 03:50:50 +0000 (23:50 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 20 Sep 2017 18:01:53 +0000 (18:01 +0000)
commit2ba76155cd0762375b8e19a500a5b1fb875ff73b
tree70bf76012196dc0655b7e4e8e061e8185915ead9
parent32dc9b247fc8393d5effb31a6673c797d75db78e
[dev.boringcrypto] crypto/internal/boring: fix finalizer-induced crashes

All the finalizer-enabled C wrappers must be careful to use
runtime.KeepAlive to ensure the C wrapper object (a Go object)
lives through the end of every C call using state that the
wrapper's finalizer would free.

This CL makes the wrappers appropriately careful.

The test proves that this is the bug I was chasing in a
separate real program, and that the KeepAlives fix it.
I did not write a test of every possible operation.

Change-Id: I627007e480f16adf8396e7f796b54e5525d9ea80
Reviewed-on: https://go-review.googlesource.com/64870
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/crypto/internal/boring/aes.go
src/crypto/internal/boring/ecdsa.go
src/crypto/internal/boring/hmac.go
src/crypto/internal/boring/rsa.go
src/crypto/rsa/boring_test.go