apache/hadoop · error

threadCreate: CreateThread failed with error %d

Error message

threadCreate: CreateThread failed with error %d

What it means

Windows port of threadCreate: CreateThread returned NULL and GetLastError supplied the code — typically ERROR_NOT_ENOUGH_MEMORY (1455, cannot reserve/commit the thread stack) under commit-limit pressure, since CreateThread commits 1MB of stack by default. The thread never starts, so later work or joins fail downstream.

Source

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

 *
 * @param toRun thread to run
 * @return DWORD result of running thread (always 0)
 */
static DWORD WINAPI runThread(LPVOID toRun) {
  const thread *t = toRun;
  t->start(t->arg);
  return 0;
}

int threadCreate(thread *t) {
  DWORD ret = 0;
  HANDLE h;
  h = CreateThread(NULL, 0, runThread, t, 0, NULL);
  if (h) {
    t->id = h;
  } 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;

View on GitHub (pinned to 2add963021)

Solutions

  1. Look up the code: 1455 → enlarge the pagefile/commit limit or stagger/bound thread creation
  2. Bound the thread pool to a fixed size
  3. If running under a job object, check its memory limits
Defensive patterns

Strategy: validation

Validate before calling

/* Windows: check commit headroom before a burst of thread creation */
MEMORYSTATUSEX st = { sizeof(st) };
GlobalMemoryStatusEx(&st);
if (st.ullAvailPageFile < 64ULL * 1024 * 1024) {
    /* too little commit left for 1MB stacks; defer spawning */
}

Try / catch

if (threadCreate(&t) != 0) {
    /* GetLastError code printed; fall back to inline execution */
    t.start(t.arg);
}

Prevention

When it happens

Trigger: Spawning threads on Windows near the commit limit (RAM + pagefile), under job-object memory caps, or with many simultaneous thread creations.

Common situations: Windows services with small pagefiles; bursty thread-pool growth; CI agents under memory pressure.

Related errors


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