{"record":{"id":"b73a0b36d070f525","repo":"openjdk/jdk","slug":"getexitcodeprocess-failed-lu","errorCode":null,"errorMessage":"GetExitCodeProcess failed: %lu\n","messagePattern":"GetExitCodeProcess failed: %lu\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java.base/windows/native/launcher/relauncher.c","lineNumber":239,"sourceCode":"    memset(&si, 0, sizeof(si));\n    si.cb = sizeof(si);\n    memset(&pi, 0, sizeof(pi));\n\n    // Windows has no equivalent of exec, so start the process and wait for it\n    // to finish, to be able to return the same exit code\n    if (!CreateProcess(java_path, command_line, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {\n        fprintf(stderr, \"CreateProcess failed: %lu\\n\", GetLastError());\n        return 1;\n    }\n\n    if (WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_FAILED) {\n        fprintf(stderr, \"WaitForSingleObject failed: %lu\\n\", GetLastError());\n        return 1;\n    }\n\n    DWORD exit_code;\n    if (!GetExitCodeProcess(pi.hProcess, &exit_code)) {\n        fprintf(stderr, \"GetExitCodeProcess failed: %lu\\n\", GetLastError());\n        return 1;\n    }\n    CloseHandle(pi.hProcess);\n    CloseHandle(pi.hThread);\n\n    return exit_code;\n}\n","sourceCodeStart":221,"sourceCodeEnd":247,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.base/windows/native/launcher/relauncher.c#L221-L247","documentation":"Windows launcher relauncher: after the spawned java process finished (or the wait failed), GetExitCodeProcess(pi.hProcess, &exit_code) returned FALSE, so the relauncher cannot forward java's exit status to the caller and returns 1. The message prints GetLastError(). Like the wait failure, on a healthy system this is nearly unreachable; it points at handle or process state corruption.","triggerScenarios":"pi.hProcess is invalid (closed by external code, job-object policies), or the process object is in a state where the exit code cannot be queried — typically caused by injected DLLs, handle-duplication bugs in launch wrappers, or antivirus terminating the child abnormally.","commonSituations":"Java launched via custom Windows service wrappers or process supervisors that mishandle inherited handles; endpoint-security software killing the child; debugging scenarios where the child was attached/detached oddly.","solutions":["Check the printed GetLastError() value (ERROR_INVALID_HANDLE = 6 is the classic one) to confirm handle corruption","Launch bin\\java.exe directly, bypassing the relauncher and any wrapper, to verify correct behavior","Fix or update the service wrapper/supervisor so it does not close or steal child process handles","Collect an hs-err file / Windows event log for the child if the security software is suspected of killing it"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure service wrappers pass (and do not close) the child process handle they wait on","Check the child's real exit status via its own logs/hs-err when the relauncher cannot propagate it"],"tags":["jdk","launcher","windows","exit-code","environment"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}