diff mbox series

[v2,1/1] libsolv: add fix for musl segfaults

Message ID 20260326114606.273018-1-adam.duskett@amarulasolutions.com
State Accepted, archived
Commit 9e5d77f86e111df91d83731d61377243e2d19495
Headers show
Series [v2,1/1] libsolv: add fix for musl segfaults | expand

Commit Message

Adam Duskett March 26, 2026, 11:46 a.m. UTC
By default, musl has a stack size of 128K, while the compress_buf
method uses 256KB of stack space, causing a segfault when the
repopagestore_compress_page method is called.

Pull request: https://github.com/openSUSE/libsolv/pull/612

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 ...0001-compress_buf-fix-musl-segfaults.patch | 44 +++++++++++++++++++
 .../libsolv/libsolv_0.7.36.bb                 |  1 +
 2 files changed, 45 insertions(+)
 create mode 100644 meta/recipes-extended/libsolv/libsolv/0001-compress_buf-fix-musl-segfaults.patch
diff mbox series

Patch

diff --git a/meta/recipes-extended/libsolv/libsolv/0001-compress_buf-fix-musl-segfaults.patch b/meta/recipes-extended/libsolv/libsolv/0001-compress_buf-fix-musl-segfaults.patch
new file mode 100644
index 0000000000..cf87b3c4c6
--- /dev/null
+++ b/meta/recipes-extended/libsolv/libsolv/0001-compress_buf-fix-musl-segfaults.patch
@@ -0,0 +1,44 @@ 
+From 23e2d4c5064ddb023ed1a9d364793dbe0d20717f Mon Sep 17 00:00:00 2001
+From: Adam Duskett <adam.duskett@amarulasolutions.com>
+Date: Thu, 26 Mar 2026 12:11:42 +0100
+Subject: [PATCH] compress_buf: fix musl segfaults
+
+By default, musl has a stack size of 128K, while the compress_buf
+method uses 256KB of stack space!
+
+The easiest course of action is to add `static thread_local`
+to htab and hnext.
+
+Upstream-Status: Submitted [https://github.com/openSUSE/libsolv/pull/612]
+
+Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
+---
+ src/repopage.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/repopage.c b/src/repopage.c
+index 77c7fcc7..470e4f34 100644
+--- a/src/repopage.c
++++ b/src/repopage.c
+@@ -29,6 +29,7 @@
+ #include <assert.h>
+ #include <fcntl.h>
+ #include <time.h>
++#include <threads.h>
+ 
+ #ifdef _WIN32
+   #include <windows.h>
+@@ -100,8 +101,8 @@ compress_buf(const unsigned char *in, unsigned int in_len,
+   unsigned int oo = 0;		/* out-offset */
+   unsigned int io = 0;		/* in-offset */
+ #define HS (65536)
+-  Ref htab[HS];
+-  Ref hnext[BLOCK_SIZE];
++  static thread_local Ref htab[HS];
++  static thread_local Ref hnext[BLOCK_SIZE];
+   unsigned int litofs = 0;
+   memset(htab, -1, sizeof (htab));
+   memset(hnext, -1, sizeof (hnext));
+-- 
+2.53.0
+
diff --git a/meta/recipes-extended/libsolv/libsolv_0.7.36.bb b/meta/recipes-extended/libsolv/libsolv_0.7.36.bb
index f22230599b..852e79c45e 100644
--- a/meta/recipes-extended/libsolv/libsolv_0.7.36.bb
+++ b/meta/recipes-extended/libsolv/libsolv_0.7.36.bb
@@ -9,6 +9,7 @@  LIC_FILES_CHKSUM = "file://LICENSE.BSD;md5=62272bd11c97396d4aaf1c41bc11f7d8"
 DEPENDS = "expat zlib zstd"
 
 SRC_URI = "git://github.com/openSUSE/libsolv.git;branch=master;protocol=https;tag=${PV} \
+           file://0001-compress_buf-fix-musl-segfaults.patch \
            file://run-ptest \
 "