[PATCH 0/2] gnu: btop: Fix SEGFAULT error on Intel GPUs; install man page.

  • Done
  • quality assurance status badge
Details
2 participants
  • Artyom V. Poptsov
  • Z572
Owner
unassigned
Submitted by
Artyom V. Poptsov
Severity
normal

Debbugs page

Artyom V. Poptsov wrote 4 months ago
(address . guix-patches@gnu.org)(name . Artyom V. Poptsov)(address . poptsov.artyom@gmail.com)
cover.1730625065.git.poptsov.artyom@gmail.com
This patchset improves btop package in two ways: firstly it fixes a SEGFAULT
error that occurs on Intel GPUs; secondly it allows btop to generate its man
page so it gets installed along with the tool.

Artyom V. Poptsov (2):
gnu: btop: Generate and install the man page.
gnu: btop: Fix SEGFAULT error on Intel GPUs.

gnu/local.mk | 1 +
gnu/packages/admin.scm | 6 ++-
.../btop-fix-segfault-on-intel-gpus.patch | 47 +++++++++++++++++++
3 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch


base-commit: 653121e1abe7e5400d39b326522ea327d90c9e58
--
2.46.0
Artyom V. Poptsov wrote 4 months ago
[PATCH 1/2] gnu: btop: Generate and install the man page.
(address . 74183@debbugs.gnu.org)(name . Artyom V. Poptsov)(address . poptsov.artyom@gmail.com)
0374d109bc8e769031e57103de11d6ae86ce257b.1730625065.git.poptsov.artyom@gmail.com
* gnu/packages/admin.scm (btop)[native-inputs]: Add lowdown to allow
generation and installation of the program man page.

Change-Id: I1eb0c9491d89f21ef408cbcb4fb10f99be46690e
---
gnu/packages/admin.scm | 2 ++
1 file changed, 2 insertions(+)

Toggle diff (22 lines)
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 86f35d49ad..bc8f0efdef 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -159,6 +159,7 @@ (define-module (gnu packages admin)
#:use-module (gnu packages m4)
#:use-module (gnu packages mail)
#:use-module (gnu packages man)
+ #:use-module (gnu packages markup)
#:use-module (gnu packages mcrypt)
#:use-module (gnu packages mpi)
#:use-module (gnu packages ncurses)
@@ -774,6 +775,7 @@ (define-public btop
(base32
"0vgw6hwqh6zbzrvrn3i0xwi9ykm1qdvhqcyz3mjakd7w303lx603"))))
(build-system gnu-build-system)
+ (native-inputs (list lowdown))
(arguments
(list #:tests? #f ;no test suite
#:make-flags #~(list (string-append "PREFIX=" #$output)
--
2.46.0
Artyom V. Poptsov wrote 4 months ago
[PATCH 2/2] gnu: btop: Fix SEGFAULT error on Intel GPUs.
(address . 74183@debbugs.gnu.org)(name . Artyom V. Poptsov)(address . poptsov.artyom@gmail.com)
a04eb3c961f20bf07290173d1b4300ecadd76197.1730625065.git.poptsov.artyom@gmail.com
btop would fail on built-in Intel GPUs, this patch fixes that (see

* gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/admin.scm (btop): Use it.

Change-Id: Ic2bbf55a5f892a37bde17db6fb15025733b9bad6
---
gnu/local.mk | 1 +
gnu/packages/admin.scm | 4 +-
.../btop-fix-segfault-on-intel-gpus.patch | 47 +++++++++++++++++++
3 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch

Toggle diff (82 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 1040b3927b..6f96cf5794 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1018,6 +1018,7 @@ dist_patch_DATA = \
%D%/packages/patches/bsd-games-number.c-and-test.patch \
%D%/packages/patches/bsd-games-prevent-name-collisions.patch \
%D%/packages/patches/bsd-games-stdio.h.patch \
+ %D%/packages/patches/btop-fix-segfault-on-intel-gpus.patch \
%D%/packages/patches/beancount-disable-googleapis-fonts.patch \
%D%/packages/patches/beignet-correct-file-names.patch \
%D%/packages/patches/bidiv-update-fribidi.patch \
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index bc8f0efdef..4ae4db641f 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -773,7 +773,9 @@ (define-public btop
(file-name (git-file-name name version))
(sha256
(base32
- "0vgw6hwqh6zbzrvrn3i0xwi9ykm1qdvhqcyz3mjakd7w303lx603"))))
+ "0vgw6hwqh6zbzrvrn3i0xwi9ykm1qdvhqcyz3mjakd7w303lx603"))
+ (patches
+ (search-patches "btop-fix-segfault-on-intel-gpus.patch"))))
(build-system gnu-build-system)
(native-inputs (list lowdown))
(arguments
diff --git a/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch b/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch
new file mode 100644
index 0000000000..d3618a374a
--- /dev/null
+++ b/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch
@@ -0,0 +1,47 @@
+From 0ed4e9e907b3a3f1c2ae209b1dab384b1fa7a490 Mon Sep 17 00:00:00 2001
+From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
+Date: Sun, 3 Nov 2024 09:02:45 +0300
+Subject: [PATCH] intel_name_lookup_shim.c (get_intel_device_name): Fix
+ SEGFAULT
+
+btop would always fail with "Segmentation fault" when used on machines where the
+GPU does not have a codename (e.g. on embedded Intel graphics on Intel(R)
+Atom(TM) CPU D2500.) The reason for this behavior is that when a GPU does not
+have codename (it is NULL) the call to "strcpy" segfaults as the procedure
+effectively tries to access a NULL pointer.
+
+* src/linux/intel_gpu_top/intel_name_lookup_shim.c (get_intel_device_name): Add
+a check if "info->codename" is null; if it is, set the device name to
+"(unknown)" to prevent the SEGFAULT error.
+---
+ src/linux/intel_gpu_top/intel_name_lookup_shim.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/src/linux/intel_gpu_top/intel_name_lookup_shim.c b/src/linux/intel_gpu_top/intel_name_lookup_shim.c
+index e714f80..38f87fa 100644
+--- a/src/linux/intel_gpu_top/intel_name_lookup_shim.c
++++ b/src/linux/intel_gpu_top/intel_name_lookup_shim.c
+@@ -84,10 +84,14 @@ char *get_intel_device_name(const char *device_id) {
+ char full_name[256];
+ const struct intel_device_info *info = intel_get_device_info(devid);
+ if (info) {
+- strcpy(dev_name, info->codename);
+- dev_name[0] = toupper(dev_name[0]);
++ if (info->codename == NULL) {
++ strcpy(dev_name, "(unknown)");
++ } else {
++ strcpy(dev_name, info->codename);
++ dev_name[0] = toupper(dev_name[0]);
++ }
+ snprintf(full_name, sizeof(full_name), "Intel %s (Gen%u)", dev_name, info->graphics_ver);
+ return strdup(full_name);
+ }
+ return NULL;
+-}
+\ No newline at end of file
++}
+
+base-commit: 2e7208d59c54515080027a5ecbb89d2054047985
+--
+2.46.0
+
--
2.46.0
Z572 wrote 4 months ago
(name . Artyom V. Poptsov)(address . poptsov.artyom@gmail.com)(address . 74183@debbugs.gnu.org)
87h68ok5q1.fsf@iscas.ac.cn
"Artyom V. Poptsov" <poptsov.artyom@gmail.com> writes:

Toggle quote (49 lines)
> btop would fail on built-in Intel GPUs, this patch fixes that (see
> <https://github.com/aristocratos/btop/pull/958>.)
>
> * gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> * gnu/packages/admin.scm (btop): Use it.
>
> Change-Id: Ic2bbf55a5f892a37bde17db6fb15025733b9bad6
> ---
> gnu/local.mk | 1 +
> gnu/packages/admin.scm | 4 +-
> .../btop-fix-segfault-on-intel-gpus.patch | 47 +++++++++++++++++++
> 3 files changed, 51 insertions(+), 1 deletion(-)
> create mode 100644 gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 1040b3927b..6f96cf5794 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1018,6 +1018,7 @@ dist_patch_DATA = \
> %D%/packages/patches/bsd-games-number.c-and-test.patch \
> %D%/packages/patches/bsd-games-prevent-name-collisions.patch \
> %D%/packages/patches/bsd-games-stdio.h.patch \
> + %D%/packages/patches/btop-fix-segfault-on-intel-gpus.patch \
> %D%/packages/patches/beancount-disable-googleapis-fonts.patch \
> %D%/packages/patches/beignet-correct-file-names.patch \
> %D%/packages/patches/bidiv-update-fribidi.patch \
> diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
> index bc8f0efdef..4ae4db641f 100644
> --- a/gnu/packages/admin.scm
> +++ b/gnu/packages/admin.scm
> @@ -773,7 +773,9 @@ (define-public btop
> (file-name (git-file-name name version))
> (sha256
> (base32
> - "0vgw6hwqh6zbzrvrn3i0xwi9ykm1qdvhqcyz3mjakd7w303lx603"))))
> + "0vgw6hwqh6zbzrvrn3i0xwi9ykm1qdvhqcyz3mjakd7w303lx603"))
> + (patches
> + (search-patches "btop-fix-segfault-on-intel-gpus.patch"))))
> (build-system gnu-build-system)
> (native-inputs (list lowdown))
> (arguments
> diff --git a/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch b/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch
> new file mode 100644
> index 0000000000..d3618a374a
> --- /dev/null
> +++ b/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch
> @@ -0,0 +1,47 @@

btop-fix-segfault-on-intel-gpus.patch, Let others know the source
without having to look it up. other LGTM.

Toggle quote (47 lines)
> +From 0ed4e9e907b3a3f1c2ae209b1dab384b1fa7a490 Mon Sep 17 00:00:00 2001
> +From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
> +Date: Sun, 3 Nov 2024 09:02:45 +0300
> +Subject: [PATCH] intel_name_lookup_shim.c (get_intel_device_name): Fix
> + SEGFAULT
> +
> +btop would always fail with "Segmentation fault" when used on machines where the
> +GPU does not have a codename (e.g. on embedded Intel graphics on Intel(R)
> +Atom(TM) CPU D2500.) The reason for this behavior is that when a GPU does not
> +have codename (it is NULL) the call to "strcpy" segfaults as the procedure
> +effectively tries to access a NULL pointer.
> +
> +* src/linux/intel_gpu_top/intel_name_lookup_shim.c (get_intel_device_name): Add
> +a check if "info->codename" is null; if it is, set the device name to
> +"(unknown)" to prevent the SEGFAULT error.
> +---
> + src/linux/intel_gpu_top/intel_name_lookup_shim.c | 10 +++++++---
> + 1 file changed, 7 insertions(+), 3 deletions(-)
> +
> +diff --git a/src/linux/intel_gpu_top/intel_name_lookup_shim.c b/src/linux/intel_gpu_top/intel_name_lookup_shim.c
> +index e714f80..38f87fa 100644
> +--- a/src/linux/intel_gpu_top/intel_name_lookup_shim.c
> ++++ b/src/linux/intel_gpu_top/intel_name_lookup_shim.c
> +@@ -84,10 +84,14 @@ char *get_intel_device_name(const char *device_id) {
> + char full_name[256];
> + const struct intel_device_info *info = intel_get_device_info(devid);
> + if (info) {
> +- strcpy(dev_name, info->codename);
> +- dev_name[0] = toupper(dev_name[0]);
> ++ if (info->codename == NULL) {
> ++ strcpy(dev_name, "(unknown)");
> ++ } else {
> ++ strcpy(dev_name, info->codename);
> ++ dev_name[0] = toupper(dev_name[0]);
> ++ }
> + snprintf(full_name, sizeof(full_name), "Intel %s (Gen%u)", dev_name, info->graphics_ver);
> + return strdup(full_name);
> + }
> + return NULL;
> +-}
> +\ No newline at end of file
> ++}
> +
> +base-commit: 2e7208d59c54515080027a5ecbb89d2054047985
> +--
> +2.46.0
> +
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEfr6klGDOXiwIdX/bO1qpk+Gi3/AFAmcnRwYACgkQO1qpk+Gi
3/DXkg//RxuGWLvrC0F7RKwVSh804PeSO62CcRFNvQTEq7KLA47gazouVgzI5jhX
Imc57IaXsevsP5t2FZFoHChtrlLWfT5pQTzDiTsh/vQqpCkL39uTNVnVeDL6eXLA
x+3ymITSRPJGPYOV7IYufrjK4BlTCHAwh9xd82PIWI87KRrubbQ81kSIOyBeb/vy
I5EA1TLqO57wIpqmO+rH7Lx23n43Yg9Xosmm1meV/oIZ5wc5aROIibJjCD5RSrRR
lDRaCsbJ4Ki5Psn24v1whewDsT40+JLXnwAzQLJdHkKo/IaB3W/qGuQvr3rk6daP
Yi0AyefYXtum1CCynF5jUEhNUD92UwrkS8i0W5lS3vFEGU3Ecpplxn5FIUvBfiy1
qoJgX3HlBfihFNvX9O1OFLz/f7RQIPMJKejb8plgxCzPtFwMcsfZ//RIFDUgPq5k
Nl0FFBXtMg2z1azMI63edF67fwzCoXVR+jFOTGS4WW3OrDs+sdHqoDqh8GCFXwBm
UO6FG2OcLLseNqOm0zZ7qpNncNV9Sz7m5HuZyO1DGNvklbEytVmvGaH7I1OJLydt
6GPzwIv7qd1laLb0OyfmNfI5AdCHcaRNbj05jm0Tvy06gcOeI64EjOgZoXcYMjYK
iE/1lVHJAUce5CwKfCULglLvjRj768L+yNKeUKfcP6lsSFHETpw=
=uBym
-----END PGP SIGNATURE-----

Artyom V. Poptsov wrote 4 months ago
Re: [PATCH 0/2] gnu: btop: Fix SEGFAULT error on Intel GPUs; install man page.
(address . 74183-done@debbugs.gnu.org)
87plncpqrz.fsf@gmail.com
Reviewed by Z572 <zhengjunjie@iscas.ac.cn>.

Merged to the "master" branch as:
- 0d7115b867424240425e5eef20efcf6abf6b7e92
- da70c25a3b6e722a16e15e758373b08d1099ded1

- avp

--
Artyom "avp" Poptsov <poptsov.artyom@gmail.com>
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE B57C E9C5 A2D9 0898 A02F
-----BEGIN PGP SIGNATURE-----

iQJNBAEBCgA3FiEEAf2F9Bp7f4IFgwalk16+BzbchX4FAmcnTTIZHHBvcHRzb3Yu
YXJ0eW9tQGdtYWlsLmNvbQAKCRCTXr4HNtyFfiOuD/9aFNis0X3b9+BSYcM2eSmr
YU5hoYeeY6mV40EWiTuzxDDhoYlQbSCvTk2jnTOAxIhSJce57u9o8pmflQZnaJ7M
OSMRiJqVZxpnOJQ701o7axUmvxQ2trNdYk965lBfX5DsKpPoBSGQqV6BvgiCxLVe
15z9KUPnRZYzbg9I2c0vY0TIZs7eZkrK5gAcAxFep2+vc8F+aE9JnmGSGlb0/2Lv
72ENcFvAC9opD4B6FeZz+3Mks/3sd4NdK1ap9aCuugULt5/V7Slkkyi4RGZgSa1v
Ii0PfTALVqx5YMnTj9ye7M02MfmlLAL3KcQuS2wixP7bNCp3h4CYooQc8ipIChZY
oBjMtEwSKtyT9pkoiIRV23YUDfUyVJXAc2F4eWUDzfLmcInfHVNCmR3JFlU/ALLP
QWpgg4MGe21us9ts4ShqyvuJIDCXpSdbsemoR9fXnU5MZsfdJ5ROww7G9OabM1qm
g3sLHFLyio1u+uAv/D6Hp/oEGojbagX+WXVpC83vILqlKG5qmqoMfmIH3j3jCJwT
4Ndm0uA27dkRmaXsbIWDgrsC3M5hvhtG6+ERwueJhqvmHdWBkrcPucQWtY7hBI21
aUgwLV8jhtc7gv7fwuyQoJkF4Sm9LBXNtyHKar868xtrTA9+Pg1IOa8yAtPZJ8B6
uMuDyCBxTTJRjMIOy9AEfQ==
=r4v2
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 74183@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74183
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help