openjdk/jdk · error
WaitForSingleObject failed: %lu
Error message
WaitForSingleObject failed: %lu
What it means
Windows launcher relauncher: java.exe was successfully spawned, but WaitForSingleObject(pi.hProcess, INFINITE) returned WAIT_FAILED, so the relauncher cannot obtain the child's exit code and exits with 1 instead of propagating java's status. The message prints GetLastError(). Common underlying errors are invalid/garbage process handles or waiting being interrupted in unusual ways.
Source
Thrown at src/java.base/windows/native/launcher/relauncher.c:233
fprintf(stderr, "%s: executing: '%s' '%s'\n", program_name, java_path, command_line);
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
memset(&pi, 0, sizeof(pi));
// Windows has no equivalent of exec, so start the process and wait for it
// to finish, to be able to return the same exit code
if (!CreateProcess(java_path, command_line, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
fprintf(stderr, "CreateProcess failed: %lu\n", GetLastError());
return 1;
}
if (WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_FAILED) {
fprintf(stderr, "WaitForSingleObject failed: %lu\n", GetLastError());
return 1;
}
DWORD exit_code;
if (!GetExitCodeProcess(pi.hProcess, &exit_code)) {
fprintf(stderr, "GetExitCodeProcess failed: %lu\n", GetLastError());
return 1;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return exit_code;
}
View on GitHub (pinned to 88dfb74bbe)
Solutions
- Look up the GetLastError() code printed by the message for the exact failure (e.g. ERROR_INVALID_HANDLE = 6, WAIT timeout-related codes)
- Run outside sandboxing/hooking environments (job objects that close handles, injection frameworks) to isolate the interference
- Run bin\java.exe directly instead of through the relauncher to confirm the JVM itself is healthy
- If it happens in CI, ensure the agent does not kill/close child handles while the build step waits
Defensive patterns
Strategy: fallback
Prevention
- Avoid launch wrappers that close or steal child process handles (job objects with kill-on-close, DLL injectors)
- When a supervisor must manage java, have it open/keep its own duplicated handle to the child
When it happens
Trigger: The process handle became invalid between CreateProcess and the wait — e.g. the handle table was manipulated, a job-object or sandbox policy closed foreign handles, or hooking/injection software interfered with the wait. On stock Windows an INFINITE wait on a fresh process handle essentially cannot fail.
Common situations: Running java under job objects with kill-on-close semantics (CI runners tearing down jobs), sandboxing/anti-cheat-style DLL injection, or debugging tools that suspend/redirect child processes.
Related errors
- no '\' found in the full path of the executable
- GetExitCodeProcess failed: %lu
- failed to get the full path of the executable: %lu
- CreateProcess failed: %lu
- no '/' found in the full path of the executable
AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14).
Data as JSON: /api/errors/d7ef57de3e97c12c.
Report an issue: GitHub.