batchverifier: preserve the memory until the end#4672
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4672 +/- ##
==========================================
+ Coverage 54.39% 54.43% +0.04%
==========================================
Files 403 403
Lines 51921 51924 +3
==========================================
+ Hits 28240 28263 +23
+ Misses 21300 21285 -15
+ Partials 2381 2376 -5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
I believe we are doing a correct conversion from uintptr to Pointer when we process the input slices ... doesn't that mean Go will recognize unsafe.Pointer is a reference for GC purposes? https://utcc.utoronto.ca/~cks/space/blog/programming/GoUintptrVsUnsafePointer
https://groups.google.com/g/golang-nuts/c/yNis7bQG_rY/m/yaJFoSx1hgIJ
From https://pkg.go.dev/unsafe#Pointer
|
In batchVerificationImpl, the signatures, messages and publicKeys are not copied. The memory from the Go slice is used by the C code, by creating C pointers to these memory location. However, Go is not aware of this usage, and can recover the memory used by these, since no Go variable is referencing them. This may happen when the C code is evaluating them, resulting is accessing corrupted memory.
This fix tells Go to keep alive these references.