{"record":{"id":"d585003abcd99a61","repo":"abhigyanpatwari/GitNexus","slug":"setinformationjobobject-failed","errorCode":null,"errorMessage":"SetInformationJobObject failed","messagePattern":"SetInformationJobObject failed","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/process_control.py","lineNumber":263,"sourceCode":"            ctypes.POINTER(wintypes.DWORD),\n        ]\n        kernel32.QueryInformationJobObject.restype = wintypes.BOOL\n        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):","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/process_control.py#L245-L281","documentation":"After creating the job, the harness calls SetInformationJobObject with JobObjectExtendedLimitInformation (class 9) and LimitFlags = 0x00002000 (JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE). If the call returns FALSE, OSError(get_last_error()) is raised and the suspended child is killed and the job closed in the except block.","triggerScenarios":"On Windows when SetInformationJobObject fails — most often because the JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct layout/size is wrong for the running Windows version, or the handle became invalid due to a race. The except clause kills process and closes the job before re-raising.","commonSituations":"Running on an old Windows version (pre-Vista SP1) that does not support extended limits; alignment / size mismatch from a Python/ctypes version change; security software that intercepts and fails the call.","solutions":["Read the captured errno (ctypes.get_last_error() at raise time, stored on OSError.errno) — ERROR_INVALID_PARAMETER (87) suggests struct/size mismatch.","Update to a modern supported Windows build (the harness assumes Vista SP1+ extended limits).","Disable AV/EDR hooks on kernel32 and retry.","Run on Linux to bypass the Windows-job codepath entirely."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import sys, platform\nif sys.platform == 'win32':\n    # SetInformationJobObject with JobObjectExtendedLimitInformation needs Vista SP1+.\n    ver = platform.win32_ver()[0]\n    if ver in ('XP', '2003Server', 'Vista'):\n        log.warning('this Windows build may not support extended job limits')","typeGuard":null,"tryCatchPattern":"try:\n    run_managed(cmd, timeout=60)\nexcept OSError as exc:\n    if sys.platform == 'win32' and 'SetInformationJobObject' in str(exc):\n        log.error('job limit configuration failed (winerror=%s); update Windows or run on Linux', exc.winerror)\n    raise","preventionTips":["Run on a supported Windows build (Windows 8 / Server 2012 or newer).","Keep ctypes struct definitions in sync with the running kernel.","Avoid AV/EDR that intercepts kernel32."],"tags":["windows","win32","job-object","ctypes","process-control"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}