This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git
The following commit(s) were added to refs/heads/main by this push:
new 4c2983c fix(array): add nil checks in Data.Release() for childData
(#456)
4c2983c is described below
commit 4c2983c9e14ce4fb7ee9fc135815426b8f8c880f
Author: secfree <[email protected]>
AuthorDate: Wed Aug 6 02:02:49 2025 +0800
fix(array): add nil checks in Data.Release() for childData (#456)
### Rationale for this change
My program crashed with below log
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x53beb92]
goroutine 294 [running]:
github.com/apache/arrow-go/v18/arrow/array.(*Data).Release(0xc02586a5b0)
/root/go/pkg/mod/github.com/apache/arrow-go/[email protected]/arrow/array/data.go:150
+0x172
github.com/apache/arrow-go/v18/arrow/array.concat.func1()
/root/go/pkg/mod/github.com/apache/arrow-go/[email protected]/arrow/array/concat.go:528
+0x9c
github.com/apache/arrow-go/v18/arrow/array.concat({0xc14ae66008, 0x100,
0x100}, {0x83213c0, 0xb026080})
/root/go/pkg/mod/github.com/apache/arrow-go/[email protected]/arrow/array/concat.go:652
+0x3f7d
github.com/apache/arrow-go/v18/arrow/array.Concatenate({0xc104861908,
0x100, 0x12f}, {0x83213c0, 0xb026080})
/root/go/pkg/mod/github.com/apache/arrow-go/[email protected]/arrow/array/concat.go:55
+0x585
...
```
### What changes are included in this PR?
Add nil check in Data.Release() for childData to avoid crash.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
No.
---
arrow/array/data.go | 4 +++-
arrow/array/data_test.go | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/arrow/array/data.go b/arrow/array/data.go
index 62284b3..6dafd8a 100644
--- a/arrow/array/data.go
+++ b/arrow/array/data.go
@@ -147,7 +147,9 @@ func (d *Data) Release() {
}
for _, b := range d.childData {
- b.Release()
+ if b != nil {
+ b.Release()
+ }
}
if d.dictionary != nil {
diff --git a/arrow/array/data_test.go b/arrow/array/data_test.go
index adc91a8..0a08c78 100644
--- a/arrow/array/data_test.go
+++ b/arrow/array/data_test.go
@@ -136,3 +136,22 @@ func TestSizeInBytes(t *testing.T) {
}
})
}
+
+func TestDataReleaseWithNilChildData(t *testing.T) {
+ mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+ defer mem.AssertSize(t, 0)
+
+ // Create a Data object that simulates the state after a failed
concatenation
+ // where childData slice is allocated but contains nil elements
+ buffers :=
[]*memory.Buffer{memory.NewBufferBytes([]byte("test-buffer"))}
+ data := NewData(arrow.ListOf(arrow.PrimitiveTypes.Int32), 1, buffers,
nil, 0, 0)
+
+ // Simulate the scenario where childData is allocated but elements
remain nil
+ // This happens in concat.go when childData is allocated but concat()
fails
+ data.childData = make([]arrow.ArrayData, 1)
+ // data.childData[0] remains nil (simulating failed concat)
+
+ assert.NotPanics(t, func() {
+ data.Release()
+ }, "Release() should not panic when childData contains nil elements")
+}