Asthenia0412 opened a new pull request, #1377: URL: https://github.com/apache/arrow-go/pull/1377
## Background `NewDatumWithoutOwning` is documented as returning a non-owning Datum -- one that should not release the caller's underlying array when `Release()` is called. However, it returned an ordinary Datum struct, so `Release()` did free the caller's memory, leading to silent double-frees and use-after-free bugs. ## Problem The non-owning contract was unenforced. Callers following the documented non-owning semantics would corrupt memory when they (or a downstream consumer) called `Release()`. ## Solution Add a `borrowed bool` field to each Datum variant (`ScalarDatum`, `ArrayDatum`, `ChunkedDatum`, `RecordDatum`, `TableDatum`). When `borrowed == true`, `Release()` is a no-op and does not free the underlying value. `NewDatumWithoutOwning` now constructs Datums with `borrowed = true`, and `NewDatum` is made explicit for each owned type. Internal call sites in `executor.go` (`Take()`) and `exprs/exec.go` (`NewMapScalar`) that construct new owned values were updated to build owned Datums directly instead of routing through `NewDatumWithoutOwning`. ## Testing - `go build ./arrow/compute/...` -- pass - `go test ./arrow/compute/...` -- all PASS - `go vet ./arrow/compute/...` -- pass Fixes #1298 -- 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]
