Closed muktihari closed 2 days ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.94%. Comparing base (
85fb3b9
) to head (f65c526
). Report is 2 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Currently we use
append(s[:0:0], s...)
to clone a slice from an array pool. That approach comes with drawback if the slice happen to have zero len, the returning slice will share the same backing array of the array pool, causing array pool can not be freed until the returning slice become unreachable. More detail is declared here: https://github.com/golang/go/issues/68488#issuecomment-2378374828This pattern was inspired from
slices.Clone
's CL that was first introduced in Go version v1.22.0. A new CL has been merged into Go's main branch to fix this issue but it seems without a backport request, so it might not be available until v1.24.0. If that's the case, people using v1.22.0 to v1.23.X are still being affected unless we do something about it. Since we typically clone a slice from an array pool, let's create our own clone function that better suite that case.