pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/59702: sysutils/btop: multiple issues in btop-1.4.5
>Number: 59702
>Category: pkg
>Synopsis: sysutils/btop: multiple issues in btop-1.4.5
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Oct 11 07:10:00 +0000 2025
>Originator: RVP
>Release: pkgsrc-HEAD
>Organization:
>Environment:
NetBSD/amd64 11.99.3
>Description:
btop-1.4.5 on NetBSD/amd64 has multiple issues:
1. After ~34 mins., the CPU temp. and battery stats stop refreshing.
(Updating every 2 mins. x 1024 refreshes exhausts the open FDs
limit in ~34 mins.)
FIX: close the /dev/sysmon device after retrieving the proplib(3)
stats.
2. On some machines (mine, for example), `acpitz0' is never updates
and always shows a fixed value (300K).
FIX: Prefer reading `coretemp0' first. This also means doing a
regex match on the `description' value rather than a string compare.
Also, try the 1st instance of each device--ie. coretemp0, acpitz0,
thinkpad0, ...--rather than going:acpitz0, acpitz1, coretemp0, ...
3. Avoid some memory leaks due using obsolete proplib(3) functions.
>How-To-Repeat:
Run btop-1.4.5 for some time. Decrease the update time to make it fail
faster.
>Fix:
---START patch---
diff -urN btop-1.4.5.orig/src/netbsd/btop_collect.cpp btop-1.4.5/src/netbsd/btop_collect.cpp
--- btop-1.4.5.orig/src/netbsd/btop_collect.cpp 2025-09-19 20:29:22.000000000 +0000
+++ btop-1.4.5/src/netbsd/btop_collect.cpp 2025-10-11 06:24:40.171200668 +0000
@@ -52,6 +52,7 @@
#include <kvm.h>
#include <paths.h>
#include <fcntl.h>
+#include <regex.h>
#include <unistd.h>
#include <uvm/uvm_extern.h>
@@ -220,12 +221,12 @@
prop_object_t fields_array;
// List of common thermal sensors in NetBSD.
const string sensors[6] = {
- "acpitz0",
- "acpitz1",
"coretemp0",
- "coretemp1",
+ "acpitz0",
"thinkpad0",
- "amdzentemp0"
+ "amdzentemp0",
+ "coretemp1",
+ "acpitz1"
};
int fd = open(_PATH_SYSMON, O_RDONLY);
@@ -242,10 +243,9 @@
return got_sensors;
}
+ close(fd);
+
if (prop_dictionary_count(dict) == 0) {
- if (fd != -1) {
- close(fd);
- }
Logger::warning("no drivers registered for envsys");
return got_sensors;
}
@@ -261,15 +261,13 @@
}
}
if (prop_object_type(fields_array) != PROP_TYPE_ARRAY) {
- if (fd != -1) {
- close(fd);
- }
return got_sensors;
}
if (Config::getB("show_coretemp") and Config::getB("check_temp")) {
got_sensors = true;
}
+
return got_sensors;
}
@@ -294,32 +292,32 @@
return;
}
+ close(fd);
+
if (prop_dictionary_count(dict) == 0) {
- if (fd != -1) {
- close(fd);
- }
Logger::warning("no drivers registered for envsys");
return;
}
prop_object_t fields_array = prop_dictionary_get(prop_dictionary_t(dict), Cpu::cpu_sensor.c_str());
if (prop_object_type(fields_array) != PROP_TYPE_ARRAY) {
- if (fd != -1) {
- close(fd);
- }
Logger::warning("unknown device " + Cpu::cpu_sensor);
return;
}
prop_object_iterator_t fields_iter = prop_array_iterator(prop_array_t(fields_array));
if (fields_iter == NULL) {
- if (fd != -1) {
- close(fd);
- }
return;
}
+ regex_t r;
+ if (regcomp(&r, "(cpu[0-9]* )*temperature", REG_EXTENDED)) {
+ Logger::warning("regcomp() failed");
+ return;
+ }
+
string prop_description = "no description";
+ char buf[64];
while ((fields = (prop_dictionary_t) prop_object_iterator_next(prop_object_iterator_t(fields_iter))) != NULL) {
props = (prop_dictionary_t) prop_dictionary_get(fields, "device-properties");
if (props != NULL) continue;
@@ -333,16 +331,19 @@
}
- prop_description = prop_string_cstring(prop_string_t(description));
+ prop_string_copy_value(prop_string_t(description), buf, sizeof buf);
+ prop_description = buf;
- if (prop_description == "temperature") {
- current_temp = prop_number_integer_value(prop_number_t(cur_value));
+ if (regexec(&r, prop_description.c_str(), 0, NULL, 0) == 0) {
+ current_temp = prop_number_signed_value(prop_number_t(cur_value));
if (max_value != NULL) {
- current_cpu.temp_max = MUKTOC(prop_number_integer_value(prop_number_t(max_value)));
+ current_cpu.temp_max = MUKTOC(prop_number_signed_value(prop_number_t(max_value)));
}
}
}
+ regfree(&r);
+
prop_object_iterator_release(fields_iter);
prop_object_release(dict);
@@ -441,10 +442,9 @@
return {0, 0.0, 0, ""};
}
+ close(fd);
+
if (prop_dictionary_count(dict) == 0) {
- if (fd != -1) {
- close(fd);
- }
has_battery = false;
Logger::warning("no drivers registered for envsys");
return {0, 0.0, 0, ""};
@@ -452,9 +452,6 @@
prop_object_t fields_array = prop_dictionary_get(prop_dictionary_t(dict), "acpibat0");
if (prop_object_type(fields_array) != PROP_TYPE_ARRAY) {
- if (fd != -1) {
- close(fd);
- }
has_battery = false;
Logger::warning("unknown device 'acpibat0'");
return {0, 0.0, 0, ""};
@@ -462,9 +459,6 @@
prop_object_iterator_t fields_iter = prop_array_iterator(prop_array_t(fields_array));
if (fields_iter == NULL) {
- if (fd != -1) {
- close(fd);
- }
has_battery = false;
return {0, 0.0, 0, ""};
}
@@ -476,6 +470,7 @@
int64_t max_charge = 0;
string status = "unknown";
string prop_description = "no description";
+ char buf[64];
while ((fields = (prop_dictionary_t) prop_object_iterator_next(prop_object_iterator_t(fields_iter))) != NULL) {
props = (prop_dictionary_t) prop_dictionary_get(fields, "device-properties");
@@ -490,23 +485,26 @@
}
- prop_description = prop_string_cstring(prop_string_t(description));
+ prop_string_copy_value(prop_string_t(description), buf, sizeof buf);
+ prop_description = buf;
if (prop_description == "charge") {
if (max_value == NULL) {
continue;
}
- cur_charge = prop_number_integer_value(prop_number_t(cur_value));
- max_charge = prop_number_integer_value(prop_number_t(max_value));
+ cur_charge = prop_number_signed_value(prop_number_t(cur_value));
+ max_charge = prop_number_signed_value(prop_number_t(max_value));
}
if (prop_description == "present") {
- is_present = prop_number_integer_value(prop_number_t(cur_value));
+ is_present = prop_number_signed_value(prop_number_t(cur_value));
}
if (prop_description == "charging") {
status = prop_description;
- string charging_type = prop_string_cstring(prop_string_t(prop_dictionary_get(fields, "type")));
+ char buf[64];
+ prop_string_copy_value(prop_string_t(prop_dictionary_get(fields, "type")), buf, sizeof buf);
+ string charging_type = buf;
is_battery = charging_type == "Battery charge" ? true : false;
}
---END patch---
Home |
Main Index |
Thread Index |
Old Index