diff --git a/grp/simple.gd b/grp/simple.gd index c6b1c556a7..0dc0bd1008 100644 --- a/grp/simple.gd +++ b/grp/simple.gd @@ -76,8 +76,9 @@ DeclareGlobalFunction("EpimorphismFromClassical"); ## ## ## This function returns an iterator that will run over all nonabelian simple groups, starting -## at order start if specified, up to order 10^{27} (or -- if specified -## -- order end). If the option NOPSL2 is given, groups of type +## at order start if specified, and stopping at order end if specified. +## Only orders up to 10^{27} are available. Attempting to iterate beyond that +## results in an error. If the option NOPSL2 is given, groups of type ## PSL_2(q) are omitted. ## it:=SimpleGroupsIterator(20000); diff --git a/grp/simple.gi b/grp/simple.gi index babad7ffd6..d1f9fab036 100644 --- a/grp/simple.gi +++ b/grp/simple.gi @@ -787,6 +787,19 @@ InstallGlobalFunction(SimpleGroupsIterator,function(arg) fi; nopsl2:=ValueOption("NOPSL2")=true or ValueOption("nopsl2")=true; + # The non-L2 orders come in two lists, the second loaded on demand. + # We do so early, so that a `start' beyond the data is rejected at + # once rather than after searching for it. + pos:=PositionProperty(SIMPLEGPSNONL2,x->x[1]>=start); + if pos=fail then + LOADSIMPLE2(); + pos:=PositionProperty(SIMPLEGPSNONL2,x->x[1]>=start); + if pos=fail then + Error("simple groups of order > ",SIMPLE_GROUPS_ITERATOR_RANGE, + " are not available"); + fi; + fi; + # find relevant L2 order a:=RootInt(start,3)-1; stack:=fail; @@ -796,8 +809,6 @@ InstallGlobalFunction(SimpleGroupsIterator,function(arg) stack:=a[3]; a:=a[2]; until SizeL2Q(b)>=start; - if start>=10^18 then LOADSIMPLE2(); fi; - pos:=First([1..Length(SIMPLEGPSNONL2)],x->SIMPLEGPSNONL2[x][1]>=start); return IteratorByFunctions(rec( IsDoneIterator:=IsDoneIterator_SimGp, NextIterator:=NextIterator_SimGp, diff --git a/tst/testbugfix/2026-08-15-SimpleGroupsIterator.tst b/tst/testbugfix/2026-08-15-SimpleGroupsIterator.tst new file mode 100644 index 0000000000..37d5cf4362 --- /dev/null +++ b/tst/testbugfix/2026-08-15-SimpleGroupsIterator.tst @@ -0,0 +1,17 @@ +# The orders of the non-PSL(2,q) simple groups come in two lists, the second +# loaded on demand. `SimpleGroupsIterator' asked for it when `start' reached +# 10^18, but the first list ends at 911215823217986880; in between nothing was +# loaded, `pos' stayed `fail', and building the iterator broke on indexing the +# list with it. +gap> it := SimpleGroupsIterator(10^18-1, 10^18-1);; +gap> IsDoneIterator(it); +true +gap> it := SimpleGroupsIterator(10^18-1, 11*10^17 : NOPSL2);; +gap> l := [];; for g in it do Add(l, g); od; +gap> List(l, Size); +[ 1053927211015007280 ] + +# An order beyond the data is rejected when the iterator is built, before the +# search for the PSL(2,q) order to start from. +gap> SimpleGroupsIterator(10^28, 10^28); +Error, simple groups of order > 1000000000000000000000000000 are not available