avp pushed a commit to branch master
in repository guix.

commit da70c25a3b6e722a16e15e758373b08d1099ded1
Author: Artyom V. Poptsov <[email protected]>
AuthorDate: Sun Nov 3 12:01:04 2024 +0300

    gnu: btop: Fix SEGFAULT error on Intel GPUs.
    
    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
    Reviewed-by: Z572 <[email protected]>
---
 gnu/local.mk                                       |  1 +
 gnu/packages/admin.scm                             |  4 +-
 .../patches/btop-fix-segfault-on-intel-gpus.patch  | 49 ++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 5b28de35f2..3b94e6cc7e 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 cd5a76579d..88d68a3afc 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -775,7 +775,9 @@ console.")
               (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..27e2541dbc
--- /dev/null
+++ b/gnu/packages/patches/btop-fix-segfault-on-intel-gpus.patch
@@ -0,0 +1,49 @@
+From 0ed4e9e907b3a3f1c2ae209b1dab384b1fa7a490 Mon Sep 17 00:00:00 2001
+From: "Artyom V. Poptsov" <[email protected]>
+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.
+
+See <https://github.com/aristocratos/btop/pull/958>.
+
+* 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
+

Reply via email to