Page MenuHomeFreeBSD

systat: Avoid incorrect reallocation in pigs.c
ClosedPublic

Authored by ota_j.email.ne.jp on Mar 17 2021, 12:42 AM.
Tags
None
Referenced Files
F121945228: D29303.diff
Mon, Jun 30, 9:38 PM
F121887470: D29303.id87888.diff
Mon, Jun 30, 8:41 AM
Unknown Object (File)
Sun, Jun 29, 9:37 PM
Unknown Object (File)
Sun, Jun 29, 6:35 AM
Unknown Object (File)
Thu, Jun 19, 7:14 AM
Unknown Object (File)
Mon, Jun 16, 5:56 PM
Unknown Object (File)
Sat, Jun 14, 7:22 PM
Unknown Object (File)
Mon, Jun 9, 6:16 PM

Details

Summary

Let's say nproc comes back in 3, 1, 2, the reallocation happens on the 3rd
fetch given lastnproc 1 is smaller than nproc 2. However, we reserved 3 slots
and thus don't need to reallocate.

Stop free() even if kvm_getprocs as we can come back but set nprocs = 0.
Check nprocs in showpigs() to ensure not try displaying with kvm_getprocs failed.
Current code can have pt with non-null after kvm_getprocs() failure.

Replace to realloc for simpler operations.

Test Plan

% systat -pigs

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37885
Build 34774: arc lint + arc unit