{"record":{"id":"06d930a63d005621","repo":"argoproj/argo-workflows","slug":"failed-to-open-remote-thread-in-target-process-d","errorCode":null,"errorMessage":"failed to open remote thread in target process %d: %w","messagePattern":"failed to open remote thread in target process (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/executor/osspecific/signal_windows.go","lineNumber":81,"sourceCode":"// Code +/- copied from: https://github.com/microsoft/hcsshim/blob/1d69a9c658655b77dd4e5275bff99caad6b38416/internal/jobcontainers/process.go#L251\n// License: MIT\n// Author: Microsoft\nfunc signalProcess(pid uint32, signal int) error {\n\thProc, err := windows.OpenProcess(windows.PROCESS_TERMINATE, true, pid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open process: %w\", err)\n\t}\n\tdefer func() {\n\t\t_ = windows.Close(hProc)\n\t}()\n\n\tif err := procCtrlRoutine.Find(); err != nil {\n\t\treturn fmt.Errorf(\"failed to load CtrlRoutine: %w\", err)\n\t}\n\n\tthreadHandle, err := createRemoteThread(hProc, nil, 0, procCtrlRoutine.Addr(), uintptr(signal), 0, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open remote thread in target process %d: %w\", pid, err)\n\t}\n\tdefer func() {\n\t\t_ = windows.Close(windows.Handle(threadHandle))\n\t}()\n\treturn nil\n}\n\n// Following code has been generated using github.com/Microsoft/go-winio/tools/mkwinsyscall and inlined\n// for easier usage\n\n// HANDLE CreateRemoteThread(\n//\n//\tHANDLE                 hProcess,\n//\tLPSECURITY_ATTRIBUTES  lpThreadAttributes,\n//\tSIZE_T                 dwStackSize,\n//\tLPTHREAD_START_ROUTINE lpStartAddress,\n//\tLPVOID                 lpParameter,\n//\tDWORD                  dwCreationFlags,","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/executor/osspecific/signal_windows.go#L63-L99","documentation":"After resolving CtrlRoutine, signalProcess injects a thread into the target process with createRemoteThread(hProc, ..., procCtrlRoutine.Addr(), signal, ...) to emulate a console signal (e.g. CTRL_BREAK) on Windows. If thread creation in the remote process fails, the signal could not be delivered and this wrapped error is returned.","triggerScenarios":"Kill() → signalProcess() where createRemoteThread fails on a valid process handle — handle lacks THREAD_CREATE rights, the target process is exiting, or address space/quota restrictions apply.","commonSituations":"Target process terminating concurrently so remote thread creation is rejected; container/job-object security descriptors blocking thread injection; resource exhaustion (max threads/handles) in the target.","solutions":["Check the wrapped Windows error: ERROR_ACCESS_DENIED → privileges; ERROR_NOT_ENOUGH_MEMORY/quota → target resource limits","If the process is already exiting, treat the signal failure as benign and verify completion via the exit-code file instead","Run argoexec with sufficient token privileges for cross-process thread creation in job containers","Fall back to TerminateProcess-style hard kill if graceful signaling is not required"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// ensure handle allows thread creation\nh, err := windows.OpenProcess(windows.PROCESS_TERMINATE|windows.PROCESS_CREATE_THREAD|windows.PROCESS_QUERY_INFORMATION, true, pid)\nif err != nil { return err }\nwindows.Close(h)","typeGuard":null,"tryCatchPattern":"if err := osspecific.Kill(pid); err != nil && strings.Contains(err.Error(), \"remote thread\") {\n    // graceful signal failed; fall back to TerminateProcess or accept process-exiting race\n}","preventionTips":["Treat signal-during-exit races as benign and verify completion via exit-code files","Grant argoexec thread-creation rights in the container token","Have a hard-kill fallback path for Windows signal delivery"],"tags":["windows","signals","process","executor"],"backgroundTag":"remote-thread-creation-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}