Skip to content

Commit 9e5d77f

Browse files
Adam Duskettrpurdie
authored andcommitted
libsolv: add fix for musl segfaults
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: openSUSE/libsolv#612 Signed-off-by: Adam Duskett <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
1 parent 55061de commit 9e5d77f

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 23e2d4c5064ddb023ed1a9d364793dbe0d20717f Mon Sep 17 00:00:00 2001
2+
From: Adam Duskett <[email protected]>
3+
Date: Thu, 26 Mar 2026 12:11:42 +0100
4+
Subject: [PATCH] compress_buf: fix musl segfaults
5+
6+
By default, musl has a stack size of 128K, while the compress_buf
7+
method uses 256KB of stack space!
8+
9+
The easiest course of action is to add `static thread_local`
10+
to htab and hnext.
11+
12+
Upstream-Status: Submitted [https://github.com/openSUSE/libsolv/pull/612]
13+
14+
Signed-off-by: Adam Duskett <[email protected]>
15+
---
16+
src/repopage.c | 5 +++--
17+
1 file changed, 3 insertions(+), 2 deletions(-)
18+
19+
diff --git a/src/repopage.c b/src/repopage.c
20+
index 77c7fcc7..470e4f34 100644
21+
--- a/src/repopage.c
22+
+++ b/src/repopage.c
23+
@@ -29,6 +29,7 @@
24+
#include <assert.h>
25+
#include <fcntl.h>
26+
#include <time.h>
27+
+#include <threads.h>
28+
29+
#ifdef _WIN32
30+
#include <windows.h>
31+
@@ -100,8 +101,8 @@ compress_buf(const unsigned char *in, unsigned int in_len,
32+
unsigned int oo = 0; /* out-offset */
33+
unsigned int io = 0; /* in-offset */
34+
#define HS (65536)
35+
- Ref htab[HS];
36+
- Ref hnext[BLOCK_SIZE];
37+
+ static thread_local Ref htab[HS];
38+
+ static thread_local Ref hnext[BLOCK_SIZE];
39+
unsigned int litofs = 0;
40+
memset(htab, -1, sizeof (htab));
41+
memset(hnext, -1, sizeof (hnext));
42+
--
43+
2.53.0
44+

meta/recipes-extended/libsolv/libsolv_0.7.36.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LIC_FILES_CHKSUM = "file://LICENSE.BSD;md5=62272bd11c97396d4aaf1c41bc11f7d8"
99
DEPENDS = "expat zlib zstd"
1010

1111
SRC_URI = "git://github.com/openSUSE/libsolv.git;branch=master;protocol=https;tag=${PV} \
12+
file://0001-compress_buf-fix-musl-segfaults.patch \
1213
file://run-ptest \
1314
"
1415

0 commit comments

Comments
 (0)