{"record":{"id":"23f9a8d0672abf7b","repo":"abhigyanpatwari/GitNexus","slug":"ntresumeprocess-failed","errorCode":null,"errorMessage":"NtResumeProcess failed","messagePattern":"NtResumeProcess failed","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/process_control.py","lineNumber":269,"sourceCode":"        ntdll.NtResumeProcess.restype = wintypes.LONG\n\n        handle = kernel32.CreateJobObjectW(None, None)\n        if not handle:\n            raise OSError(ctypes.get_last_error(), \"CreateJobObjectW failed\")\n        self._kernel32 = kernel32\n        self._handle = handle\n        ownership_slot[-1] = (process, self, None)\n        try:\n            limits = JOBOBJECT_EXTENDED_LIMIT_INFORMATION()\n            limits.BasicLimitInformation.LimitFlags = 0x00002000  # KILL_ON_JOB_CLOSE\n            if not kernel32.SetInformationJobObject(handle, 9, ctypes.byref(limits), ctypes.sizeof(limits)):\n                raise OSError(ctypes.get_last_error(), \"SetInformationJobObject failed\")\n            process_handle = wintypes.HANDLE(int(process._handle))  # type: ignore[attr-defined]\n            if not kernel32.AssignProcessToJobObject(handle, process_handle):\n                raise OSError(ctypes.get_last_error(), \"AssignProcessToJobObject failed\")\n            status = int(ntdll.NtResumeProcess(process_handle))\n            if status != 0:\n                raise OSError(status, \"NtResumeProcess failed\")\n        except BaseException:\n            # The child is still suspended when assignment fails. Kill it\n            # before releasing any handle; never retry with job breakaway.\n            process.kill()\n            process.wait()\n            self.close()\n            raise\n\n    def terminate(self) -> None:\n        import ctypes\n\n        if self._handle and not self._kernel32.TerminateJobObject(self._handle, 1):\n            raise OSError(ctypes.get_last_error(), \"TerminateJobObject failed\")\n\n    def active_processes(self) -> int:\n        \"\"\"Return live members so closing the job cannot hide forced cleanup.\"\"\"\n\n        import ctypes","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/process_control.py#L251-L287","documentation":"After assigning the suspended child to the job, ntdll.NtResumeProcess is called to start it. If it returns a non-zero NTSTATUS, OSError(status, 'NtResumeProcess failed') is raised; the except block kills the still-suspended child and closes the job. This is rare and usually indicates the process already exited or the handle is invalid.","triggerScenarios":"On Windows when NtResumeProcess returns non-zero — STATUS_INVALID_HANDLE (0xC0000008), STATUS_PROCESS_IS_TERMINATING (0xC000010A), or similar. Usually a race where the child died between CreateProcess(CREATE_SUSPENDED) and the resume call.","commonSituations":"The child process crashed or was killed by AV immediately on load; the process_handle cast from process._handle lost precision; very fast-failing executables (missing DLL, bad path).","solutions":["Decode the NTSTATUS: 0xC0000008 = invalid handle, 0xC000010A = process already terminating — both point at the child dying on launch.","Run the same command directly in cmd.exe to confirm it starts at all (look for missing DLL / bad path).","Disable AV real-time scanning briefly to see if it is killing the spawn.","Run on Linux to avoid the NtResumeProcess path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# Validate the executable exists and is launchable before the owned spawn.\nimport shutil\nif not shutil.which(cmd[0]):\n    raise FileNotFoundError(f'{cmd[0]} not on PATH; NtResumeProcess would race a fast fail')","typeGuard":null,"tryCatchPattern":"try:\n    run_managed(cmd, timeout=60)\nexcept OSError as exc:\n    if sys.platform == 'win32' and 'NtResumeProcess' in str(exc):\n        log.error('child died on launch; run %s directly to see why', cmd)\n    raise","preventionTips":["Smoke-test the command directly in cmd.exe before running the benchmark.","Disable AV real-time scanning on the executable directory.","Run on Linux to avoid the NtResumeProcess codepath."],"tags":["windows","ntdll","process-control","race"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}