zeroshade commented on code in PR #1643:
URL: https://github.com/apache/arrow-go/pull/1643#discussion_r4645186456


##########
arrow/cdata/exports.go:
##########
@@ -332,7 +332,12 @@ func asyncProducerCancel(producer *CArrowAsyncProducer) {
 func asyncTaskExtract(task *CArrowAsyncTask, out *CArrowDeviceArray) C.int {
        h := getHandle(task.private_data)
        rec := h.Value().(arrow.RecordBatch)
-       defer rec.Release()
+       // extract_data runs once per task and owns the task's handle and slot
+       defer func() {
+               rec.Release()
+               h.Delete()
+               C.free(task.private_data)

Review Comment:
   Optional: also set `task.private_data = nil` here, and have 
`asyncTaskExtract` return an error such as `EINVAL` when `private_data` is nil 
on entry. As the description says, a second `extract_data` call is now a 
use-after-free. That's a consumer bug, but this would turn it into an error 
rather than corrupted memory, for two lines.



-- 
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