!13 [sync] PR-11: 【openEuler-22.03-LTS-SP1】Backport upstream patches to fix htop crash in container
From: @openeuler-sync-bot Reviewed-by: @xiezhipeng1 Signed-off-by: @xiezhipeng1
This commit is contained in:
commit
267b6d84aa
@ -0,0 +1,50 @@
|
|||||||
|
From ba4c67942c98716fcfd1fd576421a964077cefed Mon Sep 17 00:00:00 2001
|
||||||
|
From: er-azh <80633916+er-azh@users.noreply.github.com>
|
||||||
|
Date: Sat, 26 Mar 2022 17:27:36 +0430
|
||||||
|
Subject: [PATCH] Linux: allocate cpuData before reading cpu count.
|
||||||
|
|
||||||
|
---
|
||||||
|
linux/LinuxProcessList.c | 13 ++++++++++---
|
||||||
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
|
||||||
|
index 3002e829..67493cd0 100644
|
||||||
|
--- a/linux/LinuxProcessList.c
|
||||||
|
+++ b/linux/LinuxProcessList.c
|
||||||
|
@@ -174,16 +174,19 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) {
|
||||||
|
LinuxProcessList* this = (LinuxProcessList*) super;
|
||||||
|
unsigned int existing = 0, active = 0;
|
||||||
|
|
||||||
|
- DIR* dir = opendir("/sys/devices/system/cpu");
|
||||||
|
- if (!dir) {
|
||||||
|
+ // Initialize the cpuData array before anything else.
|
||||||
|
+ if (!this->cpuData) {
|
||||||
|
this->cpuData = xReallocArrayZero(this->cpuData, super->existingCPUs ? (super->existingCPUs + 1) : 0, 2, sizeof(CPUData));
|
||||||
|
this->cpuData[0].online = true; /* average is always "online" */
|
||||||
|
this->cpuData[1].online = true;
|
||||||
|
super->activeCPUs = 1;
|
||||||
|
super->existingCPUs = 1;
|
||||||
|
- return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ DIR* dir = opendir("/sys/devices/system/cpu");
|
||||||
|
+ if (!dir)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
unsigned int currExisting = super->existingCPUs;
|
||||||
|
|
||||||
|
const struct dirent* entry;
|
||||||
|
@@ -233,6 +236,10 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) {
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
|
||||||
|
+ // return if no CPU is found
|
||||||
|
+ if (existing < 1)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
#ifdef HAVE_SENSORS_SENSORS_H
|
||||||
|
/* When started with offline CPUs, libsensors does not monitor those,
|
||||||
|
* even when they become online. */
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
25
backport-Linux-fix-crash-in-LXD.patch
Normal file
25
backport-Linux-fix-crash-in-LXD.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From 3f0c172a601574454a8f8009f3b45e89aa120475 Mon Sep 17 00:00:00 2001
|
||||||
|
From: er-azh <80633916+er-azh@users.noreply.github.com>
|
||||||
|
Date: Sat, 26 Mar 2022 15:48:12 +0430
|
||||||
|
Subject: [PATCH] Linux: fix crash in LXD
|
||||||
|
|
||||||
|
---
|
||||||
|
linux/LinuxProcessList.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
|
||||||
|
index b0e6f03a..3002e829 100644
|
||||||
|
--- a/linux/LinuxProcessList.c
|
||||||
|
+++ b/linux/LinuxProcessList.c
|
||||||
|
@@ -188,7 +188,7 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) {
|
||||||
|
|
||||||
|
const struct dirent* entry;
|
||||||
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
|
- if (entry->d_type != DT_DIR)
|
||||||
|
+ if (entry->d_type != DT_DIR && entry->d_type != DT_UNKNOWN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!String_startsWith(entry->d_name, "cpu"))
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
25
backport-use-xCalloc-for-allocating-cpuData.patch
Normal file
25
backport-use-xCalloc-for-allocating-cpuData.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From 64fb7181ee4fa4d0f2a22d202d33971899b53f08 Mon Sep 17 00:00:00 2001
|
||||||
|
From: er-azh <80633916+er-azh@users.noreply.github.com>
|
||||||
|
Date: Sun, 27 Mar 2022 12:23:56 +0430
|
||||||
|
Subject: [PATCH] use xCalloc for allocating cpuData
|
||||||
|
|
||||||
|
---
|
||||||
|
linux/LinuxProcessList.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
|
||||||
|
index 67493cd0..f365ff21 100644
|
||||||
|
--- a/linux/LinuxProcessList.c
|
||||||
|
+++ b/linux/LinuxProcessList.c
|
||||||
|
@@ -176,7 +176,7 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) {
|
||||||
|
|
||||||
|
// Initialize the cpuData array before anything else.
|
||||||
|
if (!this->cpuData) {
|
||||||
|
- this->cpuData = xReallocArrayZero(this->cpuData, super->existingCPUs ? (super->existingCPUs + 1) : 0, 2, sizeof(CPUData));
|
||||||
|
+ this->cpuData = xCalloc(2, sizeof(CPUData));
|
||||||
|
this->cpuData[0].online = true; /* average is always "online" */
|
||||||
|
this->cpuData[1].online = true;
|
||||||
|
super->activeCPUs = 1;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: htop
|
Name: htop
|
||||||
Version: 3.1.2
|
Version: 3.1.2
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: htop - an interactive process viewer
|
Summary: htop - an interactive process viewer
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
URL: https://htop.dev
|
URL: https://htop.dev
|
||||||
@ -8,6 +8,10 @@ Source0: https://github.com/htop-dev/htop/archive/%{version}.tar.gz#/%{name}-%{v
|
|||||||
|
|
||||||
BuildRequires: perl perl-PathTools ncurses-devel autoconf automake gcc
|
BuildRequires: perl perl-PathTools ncurses-devel autoconf automake gcc
|
||||||
|
|
||||||
|
Patch1: backport-Linux-fix-crash-in-LXD.patch
|
||||||
|
Patch2: backport-Linux-allocate-cpuData-before-reading-cpu-count.patch
|
||||||
|
Patch3: backport-use-xCalloc-for-allocating-cpuData.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
htop is a cross-platform interactive process viewer.
|
htop is a cross-platform interactive process viewer.
|
||||||
htop allows scrolling the list of processes vertically and horizontally to see their full command lines and related information like memory and CPU consumption.
|
htop allows scrolling the list of processes vertically and horizontally to see their full command lines and related information like memory and CPU consumption.
|
||||||
@ -34,6 +38,9 @@ Tasks related to processes (e.g. killing and renicing) can be done without enter
|
|||||||
%{_mandir}/man1/%{name}.1.gz
|
%{_mandir}/man1/%{name}.1.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 28 2023 yixiangzhike <yixiangzhike007@163.com> - 3.1.2-2
|
||||||
|
- Backport upstream patches to fix htop crash in container
|
||||||
|
|
||||||
* Wed Jan 19 2022 SimpleUpdate Robot <tc@openeuler.org> - 3.1.2-1
|
* Wed Jan 19 2022 SimpleUpdate Robot <tc@openeuler.org> - 3.1.2-1
|
||||||
- Upgrade to version 3.1.2
|
- Upgrade to version 3.1.2
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user