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
F157839582: D29303.id85869.diff
Mon, May 25, 6:26 PM
F157839556: D29303.id85869.diff
Mon, May 25, 6:25 PM
F157839480: D29303.id85869.diff
Mon, May 25, 6:25 PM
F157835393: D29303.diff
Mon, May 25, 5:44 PM
F157812232: D29303.id87888.diff
Mon, May 25, 11:28 AM
Unknown Object (File)
Mon, May 25, 12:07 AM
Unknown Object (File)
Sun, May 24, 9:45 AM
Unknown Object (File)
Sat, May 23, 11:24 AM

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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable