{"action":"created","issue":{"url":"https://api.github.com/repos/x64dbg/x64dbg/issues/1824","repository_url":"https://api.github.com/repos/x64dbg/x64dbg","labels_url":"https://api.github.com/repos/x64dbg/x64dbg/issues/1824/labels{/name}","comments_url":"https://api.github.com/repos/x64dbg/x64dbg/issues/1824/comments","events_url":"https://api.github.com/repos/x64dbg/x64dbg/issues/1824/events","html_url":"https://github.com/x64dbg/x64dbg/pull/1824","id":277146948,"number":1824,"title":"Do not keep duplicate process and initial thread handles around","user":{"login":"Mattiwatti","id":3313892,"avatar_url":"https://avatars2.githubusercontent.com/u/3313892?v=4","gravatar_id":"","url":"https://api.github.com/users/Mattiwatti","html_url":"https://github.com/Mattiwatti","followers_url":"https://api.github.com/users/Mattiwatti/followers","following_url":"https://api.github.com/users/Mattiwatti/following{/other_user}","gists_url":"https://api.github.com/users/Mattiwatti/gists{/gist_id}","starred_url":"https://api.github.com/users/Mattiwatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mattiwatti/subscriptions","organizations_url":"https://api.github.com/users/Mattiwatti/orgs","repos_url":"https://api.github.com/users/Mattiwatti/repos","events_url":"https://api.github.com/users/Mattiwatti/events{/privacy}","received_events_url":"https://api.github.com/users/Mattiwatti/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-27T19:53:14Z","updated_at":"2017-11-28T16:29:55Z","closed_at":"2017-11-28T16:29:51Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/x64dbg/x64dbg/pulls/1824","html_url":"https://github.com/x64dbg/x64dbg/pull/1824","diff_url":"https://github.com/x64dbg/x64dbg/pull/1824.diff","patch_url":"https://github.com/x64dbg/x64dbg/pull/1824.patch"},"body":"See #1759 for discussion (but scroll to the bottom, that ticket discusses like 3 separate bugs in one thread).\r\n\r\nIn the case that x64dbg starts the debuggee process, it keeps two unneeded handles around with `PROCESS_ALL_ACCESS` and `THREAD_ALL_ACCESS` rights respectively. These are duplicated in `nt!DbgkpOpenHandles` when the first debug event (`CREATE_PROCESS_DEBUG_EVENT`) is sent. The latter two handles are automatically closed by kernel32 after `EXIT_PROCESS_DEBUG_EVENT` is handled. The original handles from `CreateProcess` (done by TitanEngine) are never closed however. You can check this by starting a debug session, stopping the process, restarting the session, and so on: Process Hacker will show a leaked process handle in x64dbg.exe to a non-existent process for each session that was started.\r\n\r\nThis PR closes the initial handles received from `CreateProcess` just before calling `DebugLoop()`. `cbCreateProcess` then sets `fdProcessInfo->hProcess` and `fdProcessInfo->hThread` to the new handle values before doing anything else. This does mean there is a tiny window during which these handles are NULL, but as they aren't sent to plugins I don't think this is an issue.\r\n\r\nThe call to `SafeSymCleanup()` has been moved to `cbExitProcess`, so that this always happens before the debuggee process has terminated. This fixes a crash that can occur if you close x32dbg (but strangely not x64dbg?) while the debuggee is still running."},"comment":{"url":"https://api.github.com/repos/x64dbg/x64dbg/issues/comments/347580424","html_url":"https://github.com/x64dbg/x64dbg/pull/1824#issuecomment-347580424","issue_url":"https://api.github.com/repos/x64dbg/x64dbg/issues/1824","id":347580424,"user":{"login":"mrexodia","id":2458265,"avatar_url":"https://avatars2.githubusercontent.com/u/2458265?v=4","gravatar_id":"","url":"https://api.github.com/users/mrexodia","html_url":"https://github.com/mrexodia","followers_url":"https://api.github.com/users/mrexodia/followers","following_url":"https://api.github.com/users/mrexodia/following{/other_user}","gists_url":"https://api.github.com/users/mrexodia/gists{/gist_id}","starred_url":"https://api.github.com/users/mrexodia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrexodia/subscriptions","organizations_url":"https://api.github.com/users/mrexodia/orgs","repos_url":"https://api.github.com/users/mrexodia/repos","events_url":"https://api.github.com/users/mrexodia/events{/privacy}","received_events_url":"https://api.github.com/users/mrexodia/received_events","type":"User","site_admin":false},"created_at":"2017-11-28T16:29:55Z","updated_at":"2017-11-28T16:29:55Z","author_association":"OWNER","body":"Thanks!"}}
{"actor":{"display_login":"mrexodia"}}