From 1a0d0c8e8eb85b614eb34aa68afc03c27cfd0843 Mon Sep 17 00:00:00 2001 From: z00557007 Date: Tue, 30 May 2023 20:15:33 +0800 Subject: [PATCH] fix ps -lm dump problem --- ...ng-or-corrupted-fields-with-m-option.patch | 54 +++++++++++++++++ ...s-fix-for-final-solution-to-m-option.patch | 58 +++++++++++++++++++ procps-ng.spec | 7 ++- 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 backport-0001-ps-address-missing-or-corrupted-fields-with-m-option.patch create mode 100644 backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patch diff --git a/backport-0001-ps-address-missing-or-corrupted-fields-with-m-option.patch b/backport-0001-ps-address-missing-or-corrupted-fields-with-m-option.patch new file mode 100644 index 0000000..3ddc55e --- /dev/null +++ b/backport-0001-ps-address-missing-or-corrupted-fields-with-m-option.patch @@ -0,0 +1,54 @@ +From 35dc38cb7fcfb71b151a020abb16197b88370337 Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Wed, 24 May 2023 00:00:00 -0500 +Subject: [PATCH 1/3] ps: address missing or corrupted fields with -m option + +Coincidentally, a Debian bug report and a gitlab issue +were raised at nearly the same time and are referenced +below. They both dealt with that '-m' (thread) option. + +That option forces tasks and their threads to be shown +on separate lines. Also, information may be suppressed +between that main process and any lightweight process. + +The bottom line was sometimes a required pids_item may +not have been requested from the library before trying +to display a result. For the best case, some incorrect +results might be shown. However, in the worst case (as +with PIDS_WCHAN_NAME) a segmentation fault is created. + +[ After addressing the '-m' option problems, another ] +[ issue was found with that '-F' (extra full format) ] +[ option. The PSR (processor) field was always zero. ] +[ It was addressed in a similar manner to the above. ] + +Reference(s): +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1036631 +https://gitlab.com/procps-ng/procps/-/issues/279 + +Signed-off-by: Jim Warner +--- + src/ps/display.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/ps/display.c b/src/ps/display.c +index 4207cf87..46ac844f 100644 +--- a/src/ps/display.c ++++ b/src/ps/display.c +@@ -600,6 +600,13 @@ static void finalize_stacks (void) + // special items with 'extra' used as former pcpu + chkREL(extra) + chkREL(noop) ++ // lastly, any remaining needs ... ++ if (format_flags & FF_Uf) ++ chkREL(PROCESSOR); ++ if (thread_flags & TF_U_m) { ++ chkREL(PRIORITY); ++ chkREL(WCHAN_NAME); ++ } + + // now accommodate any results not yet satisfied + f_node = format_list; +-- +2.33.0 + diff --git a/backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patch b/backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patch new file mode 100644 index 0000000..6e5b8ac --- /dev/null +++ b/backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patch @@ -0,0 +1,58 @@ +From 93b7f05e54293af4919498fceedb236a523336df Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Fri, 26 May 2023 00:00:00 -0500 +Subject: [PATCH 2/3] ps: trade previous fix for final solution to -m option + +Well as luck would have it I found yet another missing +field (SCHED_CLASS) that's needed by that '-m' option. +And, while it could just be added to the previous test +of thread_flags and TF_U_m, here is a much better fix. + +[ The problem lies with the lists_and_needs function ] +[ where a new format list was created and some print ] +[ functions changed to pr_nop which displays a dash! ] + +[ So, by calling the finalize_stacks function before ] +[ calling lists_and_needs, the former will see those ] +[ format nodes before any print function is changed. ] + +Reference(s): +May, 2023 - missing fields with -m option +commit 35dc38cb7fcfb71b151a020abb16197b88370337 + +Signed-off-by: Jim Warner +--- + src/ps/display.c | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +diff --git a/src/ps/display.c b/src/ps/display.c +index 46ac844f..e1a3b0da 100644 +--- a/src/ps/display.c ++++ b/src/ps/display.c +@@ -600,13 +600,6 @@ static void finalize_stacks (void) + // special items with 'extra' used as former pcpu + chkREL(extra) + chkREL(noop) +- // lastly, any remaining needs ... +- if (format_flags & FF_Uf) +- chkREL(PROCESSOR); +- if (thread_flags & TF_U_m) { +- chkREL(PRIORITY); +- chkREL(WCHAN_NAME); +- } + + // now accommodate any results not yet satisfied + f_node = format_list; +@@ -676,8 +669,8 @@ int main(int argc, char *argv[]){ + + init_output(); /* must be between parser and output */ + +- lists_and_needs(); + finalize_stacks(); ++ lists_and_needs(); + + if(forest_type || sort_list) fancy_spew(); /* sort or forest */ + else simple_spew(); /* no sort, no forest */ +-- +2.33.0 + diff --git a/procps-ng.spec b/procps-ng.spec index 544b7ce..d72a6ce 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng Version: 4.0.2 -Release: 2 +Release: 3 Summary: Utilities that provide system information. License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -13,6 +13,8 @@ Patch1: openeuler-add-M-and-N-options-for-top.patch Patch2: openeuler-top-exit-with-error-when-pid-overflow.patch Patch3: skill-Restore-the-p-flag-functionality.patch Patch4: backport-top-address-the-missing-guest-tics-for-summary-area.patch +Patch5: backport-0001-ps-address-missing-or-corrupted-fields-with-m-option.patch +Patch6: backport-0002-ps-trade-previous-fix-for-final-solution-to-m-option.patch BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel systemd-pam @@ -95,6 +97,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/man* %changelog +* Tue May 30 2023 zhoujie - 4.0.2-3 +- ps: fix ps -lm dump problem + * Sat Mar 25 2023 zhoujie - 4.0.2-2 - top: top address the missing guest tics for summary area -- Gitee