Skip to content

Commit 282289b

Browse files
authored
[SYCL] Fixed assert on windows with GetModuleFileNameA failed (#1809)
This patch fixes a problem on Windows, when any unit test with invocation kernel run: `Assertion failed: Ret > 0 && "GetModuleFileNameA failed", file D:\sycl_workspace\llvm\sycl\source\detail\os_util.cpp, line 208` GetModuleFileNameA() requires 0 as the first parameter for current executable module, but it is -1 (OSUtil::ExeModuleHandle), see return value in getOSModuleHandle(). About GetModuleFileNameA() from Windows API doc : > A handle to the loaded module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path of the executable file of the current process. Signed-off-by: Alexander Flegontov <[email protected]>
1 parent 1eda3e3 commit 282289b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sycl/source/detail/os_util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ std::string OSUtil::getCurrentDSODir() {
200200
char Path[MAX_PATH];
201201
Path[0] = '\0';
202202
Path[sizeof(Path) - 1] = '\0';
203+
auto Handle = getOSModuleHandle(&getCurrentDSODir);
203204
DWORD Ret = GetModuleFileNameA(
204-
reinterpret_cast<HMODULE>(getOSModuleHandle(&getCurrentDSODir)),
205-
reinterpret_cast<LPSTR>(&Path),
206-
sizeof(Path));
205+
reinterpret_cast<HMODULE>(OSUtil::ExeModuleHandle == Handle ? 0 : Handle),
206+
reinterpret_cast<LPSTR>(&Path), sizeof(Path));
207207
assert(Ret < sizeof(Path) && "Path is longer than PATH_MAX?");
208208
assert(Ret > 0 && "GetModuleFileNameA failed");
209209
(void)Ret;

0 commit comments

Comments
 (0)