hcrosse opened a new issue, #1603:
URL: https://github.com/apache/arrow-go/issues/1603
### Describe the bug, including details regarding any error messages,
version, and platform.
`scalar.Append` and `scalar.AppendSlice` leak buffer references when
appending list scalars whose children hold buffers, such as binary values or
nested lists. Releasing the source, scalars, builder and result does not free
those buffers.
I reproduced this on v18.9.0 and `main` with Go 1.26.10 on macOS arm64.
Save this as `arrow/scalar/append_leak_test.go` and run `go test -run
TestAppendListScalarLeak ./arrow/scalar/`:
```go
package scalar_test
import (
"strings"
"testing"
"github.com/apache/arrow-go/v18/arrow"
"github.com/apache/arrow-go/v18/arrow/array"
"github.com/apache/arrow-go/v18/arrow/memory"
"github.com/apache/arrow-go/v18/arrow/scalar"
"github.com/stretchr/testify/require"
)
func TestAppendListScalarLeak(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
defer mem.AssertSize(t, 0)
dt := arrow.ListOf(arrow.BinaryTypes.Binary)
src, _, err := array.FromJSON(mem, dt, strings.NewReader(`[["YWJj"]]`))
require.NoError(t, err)
defer src.Release()
sc, err := scalar.GetScalar(src, 0)
require.NoError(t, err)
defer sc.(scalar.Releasable).Release()
bldr := array.NewBuilder(mem, dt)
defer bldr.Release()
require.NoError(t, scalar.Append(bldr, sc))
result := bldr.NewArray()
defer result.Release()
}
```
The checked allocator reports 64 bytes still allocated:
```text
invalid memory size exp=0, got=64
```
I expected zero bytes after releasing everything. `AppendSlice`, which
`Append` calls, obtains each child through `GetScalar` and does not release it
after appending, so children that hold buffers keep their references.
### Component(s)
Other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]