{"record":{"id":"b15f8ec0d51ba527","repo":"abhigyanpatwari/GitNexus","slug":"assignprocesstojobobject-failed","errorCode":null,"errorMessage":"AssignProcessToJobObject failed","messagePattern":"AssignProcessToJobObject failed","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/process_control.py","lineNumber":266,"sourceCode":"        kernel32.CloseHandle.argtypes = [wintypes.HANDLE]\n        kernel32.CloseHandle.restype = wintypes.BOOL\n        ntdll.NtResumeProcess.argtypes = [wintypes.HANDLE]\n        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:","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/process_control.py#L248-L284","documentation":"kernel32.AssignProcessToJobObject(job, process_handle) returned FALSE. On modern Windows a process can only be in one job unless nested jobs are enabled; the harness spawns the child CREATE_SUSPENDED precisely so a failed assignment can be cleaned up (process.kill() + job close) before re-raising.","triggerScenarios":"On Windows when the child is already a member of another job that does not allow nesting, or when access is denied to the job handle. Common when the parent Python process itself is already inside a Job (e.g. launched from a container, CI runner, terminal that uses jobs).","commonSituations":"Running under Docker Desktop for Windows, WSL2 broker, Visual Studio Code task, or any CI runner that wraps processes in a non-nested job; older Windows 7 / Server 2008 R2 without nested jobs enabled.","solutions":["Check OSError.errno — ERROR_ACCESS_DENIED (5) or ERROR_NOT_SUPPORTED (50) -> parent is in another non-nestable job.","Launch the benchmark from a process that is NOT already inside a Job (plain cmd.exe or PowerShell outside containers/IDE).","Upgrade to Windows 8+ where nested jobs are default (silicon-safe default).","Run the workflow bench on Linux instead, where ownership uses POSIX process groups."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import sys, ctypes\nif sys.platform == 'win32':\n    # Detect whether the parent process is already inside a non-nestable job.\n    kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)\n    # IsProcessInJob exists on Vista+; if True and nested jobs are off, expect this error.\n    in_job = ctypes.wintypes.BOOL()\n    kernel32.IsProcessInJob(kernel32.GetCurrentProcess(), None, ctypes.byref(in_job))\n    if in_job.value:\n        log.warning('parent already in a job; AssignProcessToJobObject may fail')","typeGuard":null,"tryCatchPattern":"try:\n    run_managed(cmd, timeout=60)\nexcept OSError as exc:\n    if sys.platform == 'win32' and 'AssignProcessToJobObject' in str(exc) and exc.winerror in (5, 50):\n        raise RuntimeError('launch the benchmark outside any container/IDE job (nested jobs unsupported)')\n    raise","preventionTips":["Do not launch the benchmark from Docker Desktop, WSL2, VS Code tasks, or other job-wrapped hosts.","Use Windows 8+ for nested-job support.","Prefer Linux for CI; the Windows path is for local parity only."],"tags":["windows","win32","job-object","nested-jobs","process-control"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}