Skip to content

diag(conpty): 句柄类型与 Job 句柄归属观测 (#21) - #246

Merged
JavaZeroo merged 3 commits into
mainfrom
diag/handle-types
Oct 30, 2026
Merged

JavaZeroo merged 3 commits into
mainfrom
diag/handle-types

Conversation

@JavaZeroo

Copy link
Copy Markdown
Owner

内容

为 #21 的句柄归属问题补上只读观测(不打开、不查询任何外部句柄):

新增 说明
handle_types_before/after 本进程句柄按对象类型索引分组计数(读系统句柄表 SystemExtendedHandleInformation)
handle_type_names 通过创建 Job/Event/Mutex/Semaphore/Section/IoCompletion/File 参照对象,把类型索引映射成名字
job_handles_before/after_start/after 类型 7(Job)的句柄值列表
session_job Session::job_handle() 的值(只读访问器,新增于 session.hpp)

已取得的结果(Server 2022,run 41018484448)

记录 session_job before after
startup 0xb0 [] [0xf0]
repeat 0 0xf8 [0xf0] [0xf0, 0x118]
repeat 1 0xa0 [0xf0, 0x118] [0xf0, 0x118, 0x134]
repeat 2 0xa4 [0xf0, 0x118, 0x134] [0xf0, 0x118, 0x134, 0x138]

本机 Win11:session_job start 出现、close 后消失,before/after 均 []。

即:我们自己的 job_ 每轮都被关闭,残留的是平台每轮复制进来的另一个 Job 句柄。结论已写在 #21。

验证

termforge_conpty_probe 构建通过;本机 5 个模式全部 passed;类型名映射在本机得到 {"7":"Job",...}。

边界

  • 只读观测:只读系统句柄表,不 DuplicateHandle/不 NtQueryObject 任何非自建句柄;
  • 不改判定阈值、不改 steady_resources 语义;
  • 类型名映射随 Windows 版本变化,输出中始终保留索引值。

Refs #21

The probe reads the system handle table and groups its own handles by type index, so a per-round leak names the type without opening any handle.
…t refs #21

GrantedAccess and the back-trace index precede the type index, so the earlier struct reported access masks instead of object types.
The probe now lists its Job-type handles before, during and after a session and prints the session-owned handle value, so a leak can be compared with it.
@JavaZeroo
JavaZeroo merged commit cbc2272 into main Oct 30, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant