AnsweredAssumed Answered

Calling OpenCL from a service leads to crash.

Question asked by andrei78 on Dec 25, 2014

Hello. I want to be able to make a small operations from the windows service, using OpenCL. As i know, the from the AMD APP SDK 2.5 it is possible to use the OpenCL library in the Windows Service Environment. Hovewer,  it fails to run for some reason. I made  a small test application, which gets the platforms and i'm using mingw x86 to build this application and AMD APP SDK 2.9 x64. So i took the library: libOpenCL.lib form the 'C:\Program Files (x86)\AMD APP SDK\2.9\lib\x86' folder moved it to my MinGW/lib folder, and i also moved the 'includes/CL' folder to the MinGW/includes.

So the application builds fine, but when i start it as a service, and attach the gdb debugger, things starting to get weird. Then i proceed to the instruction:

cl_int test = clGetPlatformIDs(0,NULL,&numPlatforms); under gdb. If i try to do step or next into this function, i get this:

 

100            cl_int test = clGetPlatformIDs(0,NULL,&numPlatforms);

(gdb) next

warning:

STATUS_STACK_BUFFER_OVERRUN encountered

 

 

Program received signal SIGTRAP, Trace/breakpoint trap.

0x768c025e in KERNEL32!GetProfileStringW () from C:\Windows\syswow64\kernel32.dll

(gdb) backtrace

#0  0x768c025e in KERNEL32!GetProfileStringW () from C:\Windows\syswow64\kernel32.dll

#1  0x779117b4 in RPCRT4!I_RpcInitHttpImports () from C:\Windows\syswow64\rpcrt4.dll

#2  0x77895dce in RpcExceptionFilter () from C:\Windows\syswow64\rpcrt4.dll

#3  0x77e9b499 in ntdll!LdrRemoveLoadAsDataTable () from C:\Windows\SysWOW64\ntdll.dll

#4  0x0100de48 in ?? ()

#5  0x77e9b46b in ntdll!LdrRemoveLoadAsDataTable () from C:\Windows\SysWOW64\ntdll.dll

#6  0x0100de48 in ?? ()

#7  0x77e50133 in ntdll!KiUserExceptionDispatcher () from C:\Windows\SysWOW64\ntdll.dll

#8  0x0000de48 in ?? ()

#9  0x0100de98 in ?? ()

#10 0x767e3f5f in msvcrt!_except_handler4_common () from C:\Windows\syswow64\msvcrt.dll

#11 0x767e3ed7 in msvcrt!_except_handler4_common () from C:\Windows\syswow64\msvcrt.dll

#12 0x7612bbf8 in CM_Locate_DevNodeA () from C:\Windows\syswow64\cfgmgr32.dll

#13 0x77e9b499 in ntdll!LdrRemoveLoadAsDataTable () from C:\Windows\SysWOW64\ntdll.dll

#14 0x0100e664 in ?? ()

#15 0x77e9b46b in ntdll!LdrRemoveLoadAsDataTable () from C:\Windows\SysWOW64\ntdll.dll

#16 0x0100e664 in ?? ()

#17 0x77e50133 in ntdll!KiUserExceptionDispatcher () from C:\Windows\SysWOW64\ntdll.dll

#18 0x0000e664 in ?? ()

#19 0x0100e6b4 in ?? ()

#20 0x767e3f5f in msvcrt!_except_handler4_common () from C:\Windows\syswow64\msvcrt.dll

#21 0x767e3ed7 in msvcrt!_except_handler4_common () from C:\Windows\syswow64\msvcrt.dll

#22 0x7612bbf8 in CM_Locate_DevNodeA () from C:\Windows\syswow64\cfgmgr32.dll

#23 0x77e9b499 in ntdll!LdrRemoveLoadAsDataTable () from C:\Windows\SysWOW64\ntdll.dll

#24 0x0100ee80 in ?? ()

#25 0x77e9b46b in ntdll!LdrRemoveLoadAsDataTable () from C:\Windows\SysWOW64\ntdll.dll

#26 0x0100ee80 in ?? ()

#27 0x77e50133 in ntdll!KiUserExceptionDispatcher () from C:\Windows\SysWOW64\ntdll.dll

 

However! If i do not attach the gdb to this service it works fine (i made a log of the platforms number into the file at the end of the main, and it was executed, the number of platforms was 1 which is correct). So i made the service and a console application with the same code, and tested in on a 4 different systems. On every system the console application reported the correct number of platforms, but the Service with the same code reported 0, or just the Intel Platform without any gpu. Can someone help me? How can i fix this issue? How can i make the Service Environment detect the proper gpu, rather than only Intel integrated gpu?

Outcomes