{{ message }}
fix: close pipe handles and free attribute list when conpty spawn fails#935
Open
codebytere-ant wants to merge 1 commit into
Open
Conversation
d4fc305 to
6e4d68b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
PtyConnectonly closedhandle->hIn/handle->hOutafter a successfulCreateProcessW. When spawn fails (e.g.ERROR_FILE_NOT_FOUND2,ERROR_ACCESS_DISABLED_BY_POLICY1260), the function threw before reaching thoseCloseHandlecalls, leaking both named-pipe server handles for every failed spawn. Long-running hosts that retry spawns steadily leak kernel handles.Separately, the heap-allocated
PROC_THREAD_ATTRIBUTE_LISTbuffer (attrList) was never freed on any path — success or failure — andDeleteProcThreadAttributeListwas never called.Changes
hIn/hOutand null them on theCreateProcessWfailure path; also null them after the existing success-path close soPtyKillcan tell they are already released.DeleteProcThreadAttributeList+delete[] attrListon everyPtyConnectexit (the two attribute-setup failures, theCreateProcessWfailure, and success).Napi::Errorbefore running cleanup on failure paths so the reportedGetLastError()is the real spawn error rather than a side effect ofCloseHandle/DeleteProcThreadAttributeList.hIn/hOutinPtyKillfor the case wherePtyConnectwas never called.cc @deepak1556