Skip to content

Commit 6949d81

Browse files
d-torrancemahrud
authored andcommitted
Add patch for FLINT 3.3.0 bug that caused LU decomposition segfaults
Initialize permutation vector even when there are no columns [ci skip]
1 parent b6983b7 commit 6949d81

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

M2/cmake/build-libraries.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ ExternalProject_Add(build-flint
344344
PREFIX libraries/flint
345345
SOURCE_DIR ${CMAKE_SOURCE_DIR}/submodules/flint
346346
BUILD_IN_SOURCE ON
347+
PATCH_COMMAND patch --batch -p1 < ${CMAKE_SOURCE_DIR}/libraries/flint/patch-3.3.0
347348
CONFIGURE_COMMAND ./bootstrap.sh &&
348349
${CONFIGURE} --prefix=${M2_HOST_PREFIX}
349350
${shared_setting}

M2/libraries/flint/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SUBMODULE = true
33
HOMEPAGE = http://flintlib.org
44
# git://github.com/wbhart/flint2.git
55
VERSION = 3.3.0
6-
# PATCHFILE = @abs_srcdir@/patch-$(VERSION)
6+
PATCHFILE = @abs_srcdir@/patch-$(VERSION)
77
PARALLEL = yes
88

99
# Many other tests keep failing, so disable them all:

M2/libraries/flint/patch-3.3.0

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
From e36ec985019d8ee3ef21739cc4fc6774f2336cd2 Mon Sep 17 00:00:00 2001
2+
From: Fredrik Johansson <[email protected]>
3+
Date: Sat, 14 Jun 2025 20:34:17 +0200
4+
Subject: [PATCH] gr_mat_lu_classical: set permutation vector even if there are
5+
0 columns
6+
7+
---
8+
src/gr_mat/lu_classical.c | 19 ++++++++++---------
9+
1 file changed, 10 insertions(+), 9 deletions(-)
10+
11+
diff --git a/src/gr_mat/lu_classical.c b/src/gr_mat/lu_classical.c
12+
index 003cfd5d9b..a0043d40dd 100644
13+
--- a/src/gr_mat/lu_classical.c
14+
+++ flint-3.3.0/src/gr_mat/lu_classical.c
15+
@@ -34,25 +34,26 @@ gr_mat_lu_classical(slong * res_rank, slong * P, gr_mat_t LU, const gr_mat_t A,
16+
int status = GR_SUCCESS;
17+
int pivot_status;
18+
19+
- if (gr_mat_is_empty(A, ctx) == T_TRUE)
20+
+ m = gr_mat_nrows(A, ctx);
21+
+ n = gr_mat_ncols(A, ctx);
22+
+
23+
+ rank = row = col = 0;
24+
+ for (i = 0; i < m; i++)
25+
+ P[i] = i;
26+
+
27+
+ if (m == 0 || n == 0)
28+
{
29+
*res_rank = 0;
30+
return GR_SUCCESS;
31+
}
32+
33+
- GR_TMP_INIT2(d, e, ctx);
34+
-
35+
- m = gr_mat_nrows(A, ctx);
36+
- n = gr_mat_ncols(A, ctx);
37+
sz = ctx->sizeof_elem;
38+
39+
status |= gr_mat_set(LU, A, ctx);
40+
41+
-#define ENTRY(ii, jj) GR_MAT_ENTRY(LU, ii, jj, sz)
42+
+ GR_TMP_INIT2(d, e, ctx);
43+
44+
- rank = row = col = 0;
45+
- for (i = 0; i < m; i++)
46+
- P[i] = i;
47+
+#define ENTRY(ii, jj) GR_MAT_ENTRY(LU, ii, jj, sz)
48+
49+
while (row < m && col < n)
50+
{
51+
--
52+
2.43.0
53+

0 commit comments

Comments
 (0)