apache/hadoop · warning

threadJoin: WaitForSingleObject unexpected error

Error message

threadJoin: WaitForSingleObject unexpected error %d

What it means

Windows threadJoin: WaitForSingleObject returned a value that is neither WAIT_OBJECT_0 nor WAIT_FAILED. With an INFINITE timeout on a thread handle this should be unreachable (WAIT_TIMEOUT and friends require a timeout), so it indicates handle-type confusion (waiting on a non-thread object) or corrupted handle data. The raw value is printed and returned as the join result.

Solutions

  1. Capture the raw value and confirm the HANDLE originated from threadCreate on the same struct
  2. Run with Application Verifier (handles) or a debugger to detect handle misuse
  3. Audit for writes past the end of the thread struct
Defensive patterns

Strategy: validation

Try / catch

DWORD rc = WaitForSingleObject(t.id, INFINITE);
if (rc != WAIT_OBJECT_0) {
    /* unexpected: verify the handle is a thread and not corrupted */
    assert(rc == WAIT_FAILED); /* else treat as corruption smoke */
}

Prevention

When it happens

Trigger: Passing a HANDLE that is not a thread (event/mutex/file) into threadJoin; memory corruption of the thread struct's stored handle.

Common situations: Almost never seen; when it appears, treat it as a corruption or API-misuse smoke signal in the surrounding code.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/8f1bd87adb4ca078. Report an issue: GitHub.

Appendix: source

Thrown at hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread.c:61

  } else {
    ret = GetLastError();
    fprintf(stderr, "threadCreate: CreateThread failed with error %d\n", ret);
  }
  return ret;
}

int threadJoin(const thread *t) {
  DWORD ret = WaitForSingleObject(t->id, INFINITE);
  switch (ret) {
  case WAIT_OBJECT_0:
    break;
  case WAIT_FAILED:
    ret = GetLastError();
    fprintf(stderr, "threadJoin: WaitForSingleObject failed with error %d\n",
      ret);
    break;
  default:
    fprintf(stderr, "threadJoin: WaitForSingleObject unexpected error %d\n",
      ret);
    break;
  }
  return ret;
}

View on GitHub (pinned to 2add963021)