1

This is a strange one for me. I'm currently pulling a project from an old repo of mine that I've recently migrated to VS2015. The solution still builds and the executable works, but when running in visual studio I get an access violation in the call to clGetPlatformIDs() trying to read from 0x000008E0.

I honestly have no clue what it could be as it's very strange: the builds work themselves but not from VS. Debugging through I can confirm all the parameters are as expected but the function still fails. I updated the OpenCL implementation to Intel's OpenCL SDK version 6.3 but that didn't fix the problem and I don't have the symbols to dig any deeper into the function.

Code is simple, but I've posted it below anyway.

//Get Platforms
cl_platform_id * platforms = new cl_platform_id[6];
cl_uint numPlatforms = 0;
cl_uint numPlatformsToCheck = 6;
error = clGetPlatformIDs(numPlatformsToCheck, platforms, &numPlatforms);
printCLError( "Getting Platforms", error );
6
  • Does it make any difference if you don't new the buffer for platforms? e.g., cl_platform_id platforms[6]; Apr 6, 2017 at 0:47
  • Nope, since posting the question I've tried mangling the parameters in many ways. Not only have I tried stack allocations but also making the allocated buffer much bigger than needed and pointing to somewhere in the middle of it (in case it tried to access too far before the pointer). I'm pretty sure it's not due to the buffer since the address that is getting the access violation is 0x000008E0. If it was trying to read past the bounds of the array I would expect the address to be much farther in memory and not consistent. Apr 6, 2017 at 0:53
  • 1
    I've seen several examples that want to do a two-pass query and allocation. From one of the code excerpts here: How to properly create Read and Write Buffers err = clGetPlatformIDs(0, NULL, &numPlatforms); if(numPlatforms > 0) { //we have at least one cl_platform_id* platforms = new cl_platform_id[numPlatforms]; err = clGetPlatformIDs(numPlatforms, platforms, NULL); platform_id = platforms[0]; delete[] platforms; } Apr 6, 2017 at 1:18
  • Sorry I couldn't get that formatted correctly. In any case I'm not sure why it would make a difference, but it may be worth a shot. Apr 6, 2017 at 1:23
  • How many platforms does your device have, and what are they? Apr 8, 2017 at 13:43

2 Answers 2

2

So I just had the same issue: I got an access violation exception on any OpenCL function. Fresh install of the Intel OpenCL SDK, all drivers up-to-date. Only happens when ran inside of Visual Studio.

I found a solution.

There would be an access violation in igdrcl64.dll, causing the exception. This library is part of the IntelHD Graphics drivers and there apparently used to be a bug in the DLL. But I don't have this driver installed (using NVIDIA graphics card), also the bug is supposedly fixed by now. It turns out the IntelHD driver's uninstaller does not remove all it's DLL's, so the buggy DLL's were left on my machine and not updated.

Fix: Remove the DLL's manually (only if you don't use IntelHD graphics!)

On 64-bit version of Windows OS:
C:\Windows\System32\igdbcl64.dll
C:\Windows\System32\igdfcl64.dll
C:\Windows\System32\igdrcl64.dll
C:\Windows\SysWOW64\igdbcl32.dll
C:\Windows\SysWOW64\igdfcl32.dll
C:\Windows\SysWOW64\igdrcl32.dll

On 32-bit version of Windows OS:
C:\Windows\System32\igdbcl32.dll
C:\Windows\System32\igdfcl32.dll
C:\Windows\System32\igdrcl32.dll

I hope this will help someone.

0

I think you are using clGetPlatformIDs wrong. First, call clGetPlatformIDs(numPlatformsToCheck, NULL, &numPlatforms);

Then: cl_platform_id * platforms = new cl_platform_id[numPlatforms];

Finally: error = clGetPlatformIDs(numPlatformsToCheck, platforms, NULL); printCLError( "Getting Platforms", error );

In general OpenCL query commands are:

  • Query to get number of items in a list
  • Allocate the memory for the list
  • Populate list

The issue is probably that it is either trying to find 6 platforms where there are not 6 platforms or something is funky in the library when all parameters are entered.

5
  • Even when calling clGetPlatformIDs(0, NULL, &numPlatforms); or clGetPlatformIDs(numPlatformsToCheck, NULL, &numPlatforms); I get the same access violation error in VS (but not in the executable that's created) While what you've mentioned is a good practice, I don't think it's the issue here. Apr 12, 2017 at 17:07
  • What is numPlatforms after the first call?
    – Austin
    Apr 12, 2017 at 19:29
  • Access violation halts execution, it never gets filled. In the standalone (since it works outside of visual studio) it's 3. Apr 12, 2017 at 21:47
  • What compiler and linker options are you using for debug vs release? Are you linking to an old library in the debug?
    – Austin
    Apr 14, 2017 at 12:23
  • They both link to the same library. Also, I don't think it's a debug vs release issue as running in VS will halt in either configuration. Whereas the executable created in either configuration works when ran outside of VS Apr 14, 2017 at 20:44

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.