Skip to content

Commit

Permalink
Fix bug where recursion depth is not reset on longjmp
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson committed Sep 29, 2017
1 parent 22187e2 commit 3e52ac9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@

#define TRY_READ \
if (!STATE(NrError)) { \
Int recursionDepth = STATE(RecursionDepth); \
if (sySetjmp(STATE(ReadJmpError))) { \
STATE(RecursionDepth) = recursionDepth; \
STATE(NrError)++; \
}\
}\
Expand Down
32 changes: 32 additions & 0 deletions tst/testinstall/depth.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
gap> START_TEST("depth.tst");

# We don't know what the recursion depth will be when the test starts,
# so do relative comparisons.
gap> curdepth := GetRecursionDepth();;
gap> GetRecursionDepth() - curdepth;
0
gap> dive := function(depth)
> if depth>1 then
> dive(depth-1);
> else
> Print("Depth ", GetRecursionDepth() - curdepth, "\n");
> fi;
> end;;
gap> dive(10);
Depth 10
gap> dive(500);
Depth 500
gap> SetRecursionTrapInterval(100);
gap> dive(500);
Error, recursion depth trap (100)
gap> SetRecursionTrapInterval(5000);
gap> dive(500);
Depth 500

# Just want an error to occur to check the depth is reset correctly
gap> IsAbelian(2);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsCommutative' on 1 arguments
gap> dive(500);
Depth 500
gap> STOP_TEST( "depth.tst", 1);

0 comments on commit 3e52ac9

Please sign in to comment.