AynSiddiqui opened a new issue, #1642:
URL: https://github.com/apache/arrow-go/issues/1642

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Follow-ups from #1609, on main at `aba35416`. Item 1 is code reading only; 
item 2 reproduced.
   
   1. **Tasks are not drained after `cancel`.** On `ctx.Done()`, 
`asyncTaskQueue` calls `cancel` and returns (`cdata_exports.go:531-537`). Tasks 
in `taskQueue`, and any sent later, never reach `extract_data`. The spec 
(`CDeviceDataInterface.rst:844`) says: "If the consumer does not care about the 
data that is owned by this task, it must still call `extract_data` so that the 
producer can perform any required cleanup." `abi.h:313-317` says consumers must 
expect `on_next_task` calls after cancel.
   
   2. **Per-task handle is never freed after a successful extract.** 
`exportAsyncProducer` allocates a slot and `cgo.Handle` per task 
(`exports.go:431`) and frees them only if `on_next_task` fails 
(`exports.go:443-444`). `asyncTaskExtract` (`exports.go:332-345`) releases the 
record but never calls `Delete()` or `C.free`. Repro: build 5 tasks directly 
with `createHandle(cgo.NewHandle(rec))` as `exports.go:431` does, extract each 
once; `Handle.Value()` still works for all 5, and `go test -tags test -asan` 
reports "40 byte(s) leaked in 5 allocation(s)". The end-to-end 
`TestAsyncInterfacesSimple` did not report a leak under `-asan`.
   
   **Proposed fix.** (1) After `cancel`, keep reading `taskQueue` and call 
`extract_data` with `NULL` per task until `release` closes it; 
`asyncTaskExtract` already accepts a `NULL` `out`. (2) In `asyncTaskExtract`, 
delete the handle and free the slot. `extract_data` is valid exactly once 
(`abi.h:271`), so this is safe.
   
   I can open a PR for this.
   
   ### 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]

Reply via email to