I'm debugging a crash of my OpenCL application. I attempted to use ASan to pin down where the problem originates. But then I discovered that I enable ASan when recompiling, my application cannot find any OpenCL devices. Simply adding -fsanitize=address
to the compiler options made my program unable to use OpenCL.
With further testing, I am certain ASan is the reason.
Why is this happening? How can I use asan with OpenCL?
An MVCE:
#include <CL/cl.hpp>
#include <vector>
#include <iostream>
int main() {
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
if(platforms.size() == 0)
std::cout << "Compiled with ASan\n";
else
std::cout << "Compiled normally\n";
}
cl::Platform::get
returns CL_SUCCESS
but an empty list of devices.
Some information about my setup:
GPU: GTX 780Ti
Driver: 418.56
OpenCL SDK: Nvidia OpenCL / POCL 1.3 with CPU and CUDA backend
Compiler: GCC 8.2.1
OS: Arch Linux (Kernel 5.0.7 x64)