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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   This is related to #1572 but separate. When the `on_schema` callback of a 
handler created by `cdata.CreateAsyncDeviceStreamHandler` fails, the handler's 
`release` callback panics afterwards. `on_schema` fails when the producer's 
device type isn't CPU or when `ImportCArrowSchema` returns an error.
   
   The spec says that after a non-zero return from `on_schema`, the producer 
"should not call the `on_error` callback, but instead should eventually call 
`release`". So any conforming producer hits this whenever it sends a schema 
arrow-go can't import.
   
   **Cause.** In `arrow/cdata/exports.go`:
   - `asyncStreamOnSchema` defers `C.free(self.private_data)` and `h.Delete()` 
at the top, so both run on the failure paths too.
   - Those failure paths return `C.EINVAL` without clearing `self.private_data` 
or `self.release`.
   - `asyncStreamRelease` then calls `getHandle(self.private_data)`, which 
reads the handle from memory that has already been freed. `h.Value()` panics 
with `runtime/cgo: misuse of an invalid Handle`, and the same `private_data` 
would be freed a second time.
   
   ```
   panic: runtime/cgo: misuse of an invalid Handle
   
   goroutine 17 [running, locked to thread]:
   runtime/cgo.Handle.Value(...)
        runtime/cgo/handle.go:133
   github.com/apache/arrow-go/v18/arrow/cdata.asyncStreamRelease(...)
        github.com/apache/arrow-go/[email protected]/arrow/cdata/exports.go:273
   ```
   
   **To reproduce.** Create a handler with `CreateAsyncDeviceStreamHandler`, 
and set its `producer` field to a producer with `device_type` CPU. Call 
`on_schema` with a schema `ImportCArrowSchema` rejects, for example a format 
string of `"~bogus"`. Then call `release` on the handler, as the spec says to. 
The process crashes with the panic above.
   
   ### 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