Skip to content

Commit 1653d43

Browse files
fingolfincodex
andcommitted
Fix crash in CosetLeadersMatFFE
Reject matrices with dependent rows before building the internal search tables for CosetLeadersMatFFE. This avoids a crash in the 8-bit path and restores correct behaviour for square full-rank inputs. AI assistance: Codex reproduced the crash, traced it to the internal row-independence assumption, added a regression test, and prepared the fix. Co-authored-by: Codex <codex@openai.com>
1 parent 96c73b4 commit 1653d43

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/listcoef.gi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,10 +1516,14 @@ InstallMethod(CosetLeadersMatFFE,"generic",IsCollsElms,
15161516
q := Size(f);
15171517
n := Length(mat[1]);
15181518
m := Length(mat);
1519+
# The search below assumes the rows form a basis for an m-dimensional
1520+
# syndrome space, so reject dependent input before building the column data.
1521+
if RankMat(mat) <> m then
1522+
Error("CosetLeadersMatFFE: <mat> must have linearly independent rows");
1523+
fi;
15191524
tofind := q^m;
15201525
t := TransposedMat(mat);
15211526
vl := [];
1522-
vl[m+1] := false;
15231527
felts := AsSSortedList(f);
15241528
Assert(2, felts[1] = Zero(f));
15251529
nzfelts := felts{[2..q]};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Regression test for square matrices and invalid dependent input in
2+
# CosetLeadersMatFFE.
3+
gap> M := IdentityMat(2, GF(2));;
4+
gap> L := CosetLeadersMatFFE(M, GF(2));;
5+
gap> Length(L);
6+
4
7+
gap> CosetLeadersMatFFE(L, GF(2));
8+
Error, CosetLeadersMatFFE: <mat> must have linearly independent rows

0 commit comments

Comments
 (0)