Skip to content

Commit 39d46a2

Browse files
kbenziefabiomestre
authored andcommitted
[SYCL][CUDA] Fix device creation from native handle (#10450)
In CUDA objects are represented as integers rather than opaque handles. This patch fixes a segmentation fault when creating a device handle from a native handle by avoiding dereferencing a pointer which should be treated as an integer.
1 parent 0af7d63 commit 39d46a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
11761176
// We can't cast between ur_native_handle_t and CUdevice, so memcpy the bits
11771177
// instead
11781178
CUdevice CuDevice = 0;
1179-
memcpy(&CuDevice, hNativeDevice, sizeof(CUdevice));
1179+
memcpy(&CuDevice, &hNativeDevice, sizeof(CUdevice));
11801180

11811181
auto IsDevice = [=](std::unique_ptr<ur_device_handle_t_> &Dev) {
11821182
return Dev->get() == CuDevice;

0 commit comments

Comments
 (0)