Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential infinite loop or recursion when computing size of infinite cyclic groups #3580

Merged
merged 1 commit into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/grp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ InstallMethod( IsCyclic,

InstallMethod( Size,
"for a cyclic group",
[ IsGroup and IsCyclic and HasGeneratorsOfGroup ],
[ IsGroup and IsCyclic and HasGeneratorsOfGroup and CanEasilyCompareElements ],
{} -> -RankFilter(HasGeneratorsOfGroup),
function(G)
local gens;
Expand Down
10 changes: 10 additions & 0 deletions tst/testbugfix/2019-07-17-cyclic-size.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Fix a bug that only occurs if all packages are loaded
gap> F:=FreeGroup(2);;
gap> F:=F/[F.1/F.2];;
gap> H:=Group(F.1);;
gap> IsCyclic(H);
true
gap> HasIsFinite(H);
false
gap> Size(H); # should be instant, not infinite recursion / loop
infinity