hmos-fdleak-analysis

Analyzes HarmonyOS FD leak logs to locate handle leak root causes with evidence chains.

2|Updated Jun 21, 2026
One-click install
npx skills add https://github.com/IsKenKenYa/skills --skill hmos-fdleak-analysis-iskenkenya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hmos-fdleak-analysis
Source: https://github.com/IsKenKenYa/skills/tree/main/skills/harmonyos/solutions/quality/stability/hmos-fdleak-analysis
Command: npx skills add https://github.com/IsKenKenYa/skills --skill hmos-fdleak-analysis-iskenkenya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Diagnosing file descriptor (FD) and handle leaks on HarmonyOS devices requires manually reading large diagnostic logs, correlating handle type distributions, directory clusters, per-resource details, and FdTrack allocation stacks. This Skill automates that analysis and produces a structured root-cause report with an auditable evidence chain. ## Core Features & Use Cases - Automated Log Parsing: A Python script extracts the fault snapshot (leaked fd nums), Leaked fd Top 10, Dir Type Top 10, five special-resource detail sections (ashmem, socket, pipe, sync_file, dmabuf), and FdTrack allocation stack hotspots from [pid]_fd_leak.txt or RESOURCE_OVERLIMIT_[TIMESTAMP]_[PID].log files, outputting Markdown or JSON. - Fault Mode Library Matching: Matches evidence against a built-in fault mode library covering two second-level root causes (in-process handle leak over 20000 handles, RS-side handles over 25000 with RENDER_MEMORY_OVER_WARNING) and their third-level causes such as file, ashmem, socket, dmabuf, pipe, eventpoll, and eventfd leaks. - Confidence-Graded Conclusions: Outputs a three-level root cause table, evidence chain, fix suggestions, and a HIGH/MEDIUM/LOW confidence rating while strictly distinguishing the leak snapshot from 10-minute FdTrack allocation statistics. - Use Case: A user provides a RESOURCE_OVERLIMIT_20240627115528_1380.log from a background app killed for resource overlimit; the Skill parses it, finds 1337 ashmem handles dominating the snapshot, cross-checks ashmem detail records and FdTrack stacks, and reports an ashmem handle leak with MEDIUM confidence plus symbolization advice. ## Quick Start Analyze the attached FD leak log file and produce a root-cause report with evidence chain and fix suggestions.

Frequently Asked Questions about hmos-fdleak-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze an FD leak log on HarmonyOS?

Run the bundled parser with python fd_leak_parser.py -p <log file or directory> to extract the leak snapshot, handle type Top 10, directory Top 10, special resource details, and FdTrack stacks. The Skill then matches the evidence against its fault mode library to produce a three-level root cause report.

What log files does FD leak analysis support?

It supports [pid]_fd_leak.txt and RESOURCE_OVERLIMIT_[TIMESTAMP]_[PID].log files. Given a directory, it analyzes the most recent standard log by default, or all of them with the --all flag.

Why can't FdTrack stack counts prove a handle leak?

FdTrack counts all FD allocations within 10 minutes, including FDs that were later closed, so a high num value only indicates an allocation hotspot. It must be cross-validated against the leaked fd nums snapshot and handle type distribution before concluding a leak.

Does the FD leak parser need third-party Python packages?

No, the parser uses only the Python 3 standard library. It handles utf-8-sig, utf-8, and gb18030 encodings and can output either Markdown tables or structured JSON via the --format flag.

What if the log has no FdTrack stack information?

Missing stacks do not mean there is no leak; nolog builds without developer mode may not collect FdTrack data. Analysis can still proceed using the snapshot, handle types, and detail sections, but the confidence rating should be lowered.

When do ashmem or dmabuf detail sections appear in the log?

Special detail sections for ashmem, socket, pipe, sync_file, and dmabuf are only expected when the corresponding handle count exceeds 1000. If a section is absent below that threshold, the analysis reports it as not obtained rather than fabricating data.