openjdk/jdk · error

GetExitCodeProcess failed: %lu

Error message

GetExitCodeProcess failed: %lu

What it means

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.

Source

Thrown at src/java.base/windows/native/launcher/relauncher.c:239

    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

  1. Check the printed GetLastError() value (ERROR_INVALID_HANDLE = 6 is the classic one) to confirm handle corruption
  2. Launch bin\java.exe directly, bypassing the relauncher and any wrapper, to verify correct behavior
  3. Fix or update the service wrapper/supervisor so it does not close or steal child process handles
  4. Collect an hs-err file / Windows event log for the child if the security software is suspected of killing it
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14). Data as JSON: /api/errors/b73a0b36d070f525. Report an issue: GitHub.