Skip to content

Top: fixes division by zero in disk I/O rate calculation - #2770

Merged
CarterLi merged 2 commits into
fastfetch-cli:devfrom
sagaragas:fix/top-subms-div-by-zero
Nov 30, 2026
Merged

CarterLi merged 2 commits into
fastfetch-cli:devfrom
sagaragas:fix/top-subms-div-by-zero

Conversation

@sagaragas

Copy link
Copy Markdown
Contributor

Summary

Running two top entries with "waitTime": 0 crashes fastfetch with SIGFPE when the sampling interval is under 1 ms. ffDetectTopProcesses() only rejects elapsed <= 0, so (uint64_t) elapsed truncates to 0 and divides by zero.

Changes

  • src/detection/top/top.c: divide bytesRead and bytesWritten deltas in double before casting to uint64_t (matching diskio.c and netio.c).
  • CHANGELOG.md: add bugfix entry under # Unreleased.

Checklist

  • I have tested my changes locally.

sagaragas and others added 2 commits November 29, 2026 16:13
`ffDetectTopProcesses()` rejects `elapsed <= 0`, so when `0 < elapsed < 1.0` ms,
`(uint64_t) elapsed` truncates to 0 and triggers `SIGFPE` on the disk rate
divisions (for example with `"waitTime": 0`).

Divide in `double` before casting to `uint64_t`, matching `diskio.c` and `netio.c`.
@CarterLi
CarterLi merged commit cbfaa5c into fastfetch-cli:dev Nov 30, 2026
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.

2 participants