Background
cuda.core accepts any ctypes._CFuncPtr as a CUDA host callback and casts its address to CUhostFn without validating the declared ctypes signature. CUDA requires a callback compatible with void (*)(void*); passing an incompatible return type, argument list, or calling convention can cause undefined behavior when CUDA invokes it.
The shared callback resolver is used by both host callback node construction and HostCallbackNode.update().
Scope
- Validate ctypes callback argument and return types against the
CUhostFn ABI.
- Handle platform-specific calling-convention requirements, including Windows.
- Define behavior for untyped or explicitly cast
_CFuncPtr objects without rejecting compatible existing use cases unnecessarily.
- Apply the same validation to construction and update paths.
- Add positive and negative tests, including an incompatible
CFUNCTYPE.
Acceptance criteria
- Clearly incompatible ctypes callback signatures are rejected before being passed to CUDA.
- Valid callbacks continue to work on supported platforms.
- The error identifies the required callback signature.
Background
cuda.core accepts any
ctypes._CFuncPtras a CUDA host callback and casts its address toCUhostFnwithout validating the declared ctypes signature. CUDA requires a callback compatible withvoid (*)(void*); passing an incompatible return type, argument list, or calling convention can cause undefined behavior when CUDA invokes it.The shared callback resolver is used by both host callback node construction and
HostCallbackNode.update().Scope
CUhostFnABI._CFuncPtrobjects without rejecting compatible existing use cases unnecessarily.CFUNCTYPE.Acceptance criteria