Skip to content

Panic on zero length array in exportArray #172

@ukclivecox

Description

@ukclivecox

Describe the bug, including details regarding any error messages, version, and platform.

I have seen some panics at line 410 in

out.n_children = C.int64_t(arr.NumField())
childPtrs := allocateArrowArrayPtrArr(arr.NumField())
children := allocateArrowArrayArr(arr.NumField())
for i := 0; i < arr.NumField(); i++ {
exportArray(arr.Field(i), &children[i], nil)
childPtrs[i] = &children[i]
}
out.children = (**CArrowArray)(unsafe.Pointer(&childPtrs[0]))

This is when the array childPtrs is of size 0.

Its hard to replicate, so at present my question is simply if zero length arrays should be checked for here? I assume this would be a record with 0 fields?

The panics were with a July commit of release candidate for v18 (linux x86) but wanted to check first if this is a code issue while I try to replicate.

panic: runtime error: index out of range [0] with length 0

goroutine 17 [running, locked to thread]:
github.com/apache/arrow/go/v18/arrow/cdata.exportArray({0x5564f20, 0xc001d91000}, 0x7fac48074650, 0x0)
        /home/clive/go/pkg/mod/github.com/apache/arrow/go/v18@v18.0.0-20240722165357-ec58e4de9e08/arrow/cdata/cdata_exports.go:406 +0x10a5
github.com/apache/arrow/go/v18/arrow/cdata.ExportArrowRecordBatch({0x55609b8, 0xc001509a70}, 0x7fac48074650, 0x0)
        /home/clive/go/pkg/mod/github.com/apache/arrow/go/v18@v18.0.0-20240722165357-ec58e4de9e08/arrow/cdata/interface.go:250 +0x436
github.com/apache/arrow/go/v18/arrow/cdata.cRecordReader.next({{0x554da68, 0xc001fbe140}, 0x0}, 0x7fac48074650)
        /home/clive/go/pkg/mod/github.com/apache/arrow/go/v18@v18.0.0-20240722165357-ec58e4de9e08/arrow/cdata/cdata_exports.go:449 +0x71
github.com/apache/arrow/go/v18/arrow/cdata.streamGetNext(0x7faccc00c890, 0x7fac48074650)
        /home/clive/go/pkg/mod/github.com/apache/arrow/go/v18@v18.0.0-20240722165357-ec58e4de9e08/arrow/cdata/exports.go:129 +0xbd

Component(s)

Release

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions