apache/hadoop · warning
threadJoin: WaitForSingleObject unexpected error %d
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.
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)
Solutions
- Capture the raw value and confirm the HANDLE originated from threadCreate on the same struct
- Run with Application Verifier (handles) or a debugger to detect handle misuse
- 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
- Only pass handles returned by threadCreate into threadJoin
- Run Application Verifier handle checks when this appears
- Treat as a memory-corruption smoke signal and investigate surrounding writes
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
- threadJoin: WaitForSingleObject failed with error %d
- threadCreate: CreateThread failed with error %d
- UNKNOWN
- threadJoin: pthread_join failed with error %d
- detachCurrentThreadFromJvm: GetJavaVM failed with error %d
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/8f1bd87adb4ca078.
Report an issue: GitHub.