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 several bugs (including crashes, and invalid permutations) #2766

Merged
merged 6 commits into from
Sep 4, 2018

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Aug 31, 2018

  1. remove incomplete support for !{...} syntax, fixes crashes; fixes Crash in coder/executor with foo!{[1,2,3]} syntax #2765
  2. reject invalid permutations in code and compiler, instead of producing permutation in a broken and thus potentially dangerous state. Example of the old, buggy behaviour:
gap> f:=x->(1,2,3,2);; pi:=f(0);
(1,2)
gap> 3^pi;
2
gap> ;
gap> MovedPoints(pi);
[ 1, 2, 3 ]
  1. fix crash (at least with assertions on) when coding IsBound(dvar) (probably the most obscure of the three bugs)
  2. add more tests for the interpreter and coder (creating these tests ultimately revealed the three bugs above)
  3. remove some dead code

@fingolfin fingolfin added kind: bug Issues describing general bugs, and PRs fixing them kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) topic: kernel release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Aug 31, 2018
@fingolfin fingolfin force-pushed the mh/tests branch 2 times, most recently from ddedacd to b796525 Compare August 31, 2018 22:48
@codecov
Copy link

codecov bot commented Aug 31, 2018

Codecov Report

Merging #2766 into master will increase coverage by 0.06%.
The diff coverage is 90.62%.

@@            Coverage Diff             @@
##           master    #2766      +/-   ##
==========================================
+ Coverage   75.81%   75.87%   +0.06%     
==========================================
  Files         481      481              
  Lines      241520   241325     -195     
==========================================
+ Hits       183104   183113       +9     
+ Misses      58416    58212     -204
Impacted Files Coverage Δ
src/lists.c 72.36% <ø> (+0.6%) ⬆️
src/code.h 100% <ø> (ø) ⬆️
src/lists.h 100% <ø> (ø) ⬆️
src/scanner.c 91.6% <ø> (-0.02%) ⬇️
src/vars.c 92.99% <ø> (+6.13%) ⬆️
src/scanner.h 100% <ø> (ø) ⬆️
src/compiler.c 88.13% <ø> (+0.92%) ⬆️
src/code.c 96.26% <100%> (+2.55%) ⬆️
src/read.c 96.49% <100%> (-0.06%) ⬇️
src/intrprtr.c 98.63% <100%> (+3.93%) ⬆️
... and 8 more

@olexandr-konovalov
Copy link
Member

olexandr-konovalov commented Sep 2, 2018

@fingolfin Travis currently fails - this should be fixed by #2768, let's give that PR a fast-track.

The modified functions are guaranteed to be only called if coding is
in effect. Make the code reflect that. Also update an outdated message
in the manual.
In 1999, the interpreter was fixed to reject "permutations" like
(1,2,3,2); but the same fix was not applied to the coder and compiler
code. So fix that, and also remove some other differences between the
three copies of code that crept in over time.

Ideally, this shared code would be factored out into a separate function,
but that's not completely trivial, as in one case we iterate over expressions,
in one over a GAP list, and in one over a stack of objects.
Specifically, `posobj!{indices}` was meant to relate to `list{indices}` the
same way as `posobj![i]` does to `list[i]`. But it was never fully
implemented. Specifically, no printing or execution functions for the
relevant statement and expression types were implemented; and for the
interpreter and compiler, mostly trying to use these lead to an error a long
the line of "sorry, this feature has not been implemented". Due to all this,
trying to use this feature in a coded function could trigger all kinds of
problems, up to crashes.

Since this code serves no clear purpose, we just remote it, instead of trying
to implement the missing bits.

Fixes gap-system#2765
Copy link
Contributor

@ChrisJefferson ChrisJefferson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fixes all around.

I'm quite upset (not at anyone, just in general), that we've obviously had the bugs which let invalid permutations be created, so well done for noticing!

@fingolfin fingolfin merged commit e628410 into gap-system:master Sep 4, 2018
@fingolfin fingolfin deleted the mh/tests branch September 4, 2018 19:50
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.10.0 milestone Sep 4, 2018
@fingolfin fingolfin changed the title Fix several bugs (including crashes) Fix several bugs (including crashes, and invalid permutations) Sep 12, 2018
@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Sep 20, 2018
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: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug Issues describing general bugs, and PRs fixing them release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in coder/executor with foo!{[1,2,3]} syntax
3 participants