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

Segfault after installing a silly method for a synonym attribute #4340

Open
wilfwilson opened this issue Mar 25, 2021 · 4 comments
Open

Segfault after installing a silly method for a synonym attribute #4340

wilfwilson opened this issue Mar 25, 2021 · 4 comments
Labels
kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) kind: bug Issues describing general bugs, and PRs fixing them

Comments

@wilfwilson
Copy link
Member

In the current master and stable-4.11 branches, and in 4.11.1 (I believe), I can cause a segfault in the following way:

gap> DeclareAttribute("Wilf", IsGroup);
gap> DeclareSynonymAttr("Wilson", Wilf);
gap> InstallMethod(Wilf, [IsGroup], x -> fail);
gap> InstallMethod(Wilson, [IsGroup], Wilf);
gap> Wilf(SymmetricGroup(3));
Segmentation fault: 11

Calling Wilson(SymmetricGroup(3)); instead on the final line also gives the a segfault.

The specific group involved, and indeed even the use of IsGroup as the filter rather than some other object, doesn't seem to be important.

Obviously I'm not using things correctly – the declaration as a synonym means that the line InstallMethod(Wilson, [IsGroup], Wilf); is completely unnecessary. But whatever the case, this shouldn't lead to a crash.

This shows that it is most likely the redundant method installation that causes the problem:

gap> DeclareAttribute("Wilf", IsGroup);
gap> InstallMethod(Wilf, [IsGroup], x -> fail);
gap> Wilf(SymmetricGroup(3)); # All fine
fail
gap> DeclareSynonymAttr("Wilson", Wilf);
gap> Wilf(SymmetricGroup(3)); # All fine
fail
gap> InstallMethod(Wilson, [IsGroup], Wilf);
gap> Wilf(SymmetricGroup(3));
Segmentation fault: 11

Note that doing the method installation the other way round (i.e. InstallMethod(Wilf, [IsGroup], Wilson);) also gives the segfault.

@wilfwilson wilfwilson added kind: bug Issues describing general bugs, and PRs fixing them kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) labels Mar 25, 2021
@fingolfin
Copy link
Member

I suspect this has nothing to do with synonyms; just do InstallMethod(Foo, ..., Foo); and then any call to Foo triggering this "method" will result in infinite recursion and a crash . Of course you can also do with 2, 3, ... operations calling each other in a circle

@fingolfin
Copy link
Member

As such this seems to be a duplicate of issue #1286 ? Which we closed but the fix was reverted...?

@wilfwilson
Copy link
Member Author

Ah, interesting, thanks for remembering this @fingolfin.

#1286 was fixed in #3221 but unfixed in #3578, because the fix was too expensive.

If that's how things are going to stay, then we should close this issue but re-open #1286, and add the 'status: wontfix' label (and perhaps give it a more descriptive title).

@fingolfin
Copy link
Member

Well, one thing that we definitely could do is to at least catch the "obvious" cases, were someone installs an operation as a method for itself, which is essentially what's happening here, and also in #1286:

gap> DeclareAttribute("Wilf", IsGroup);
gap> DeclareSynonymAttr("Wilson", Wilf);
gap> Wilson;
<Attribute "Wilf">
gap> IsIdenticalObj(Wilson, Wilf);
true

While that may not catch all and every potential problem, it seems that at least two people ran into this independently, so even such a limited but fast patch would still be useful. I've now made PR #4349. Unfortunately it triggers for me when loading with the default set of autoloaded packages 😂. Details in that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) kind: bug Issues describing general bugs, and PRs fixing them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants