KhronosGroup / KhronosGroup/OpenCL-CTS

svm_set_kernel_exec_info_svm_ptrs may access an SVM allocation incorrectly

Open
#2,385 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
232
Forks
235
Avg merge
8d 7h
Merged PRs (30d)
18

Description

I believe that the test for `svm_set_kernel_exec_info_svm_ptrs` is incorrect in at least some cases, specifically how it acceses the `pBuf` SVM allocation for the call to `clSetKernelExecInfo`:

https://github.com/KhronosGroup/OpenCL-CTS/blob/9fc0d23b4cfccd84be8927363a77107dc554de30/test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp#L107-L115

Note:

* `pBuf` is a (coarse-grain) SVM allocation. This means that it must be mapped and unmapped to access the data on the host.
* `pBuf` itself is never mapped or unmapped, but there is a `bBuf` OpenCL buffer object that is created with the `pBuf` coarse-grain SVM allocation, which is mapped and unmapped to populate the SVM allocation.
* The command to unmap the `bBuf` OpenCL buffer object has been enqueued at the time of the call to `clSetKernelExecInfo`, so the buffer object may be unmapped (and therefore, `pBuf` may be inaccessible) at the call to `clSetKernelExecInfo`, depending whether the unmap command is executed greedily or lazily.

Here are two possible ways to make this test safe in all cases. There may be others, too:

1. Call `clSetKernelExecInfo` before unmapping `bBuf`, where the `pBuf` pointer is guaranteed to be accessible.
2. Pass a separate host pointer to `clSetKernelExecInfo` rather than reusing `pBuf` for this purpose.

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp around lines 107-115, focusing on how pBuf and bBuf are used before clSetKernelExecInfo. Verify the test does not access the coarse-grain SVM allocation while it is unmapped, then run the relevant SVM test to confirm the corrected ordering or pointer usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.