Skip to content

Commit

Permalink
Do not call back into GAP code when we are already quitting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson committed Mar 10, 2022
1 parent 516e42e commit f552fac
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,14 @@ static Int GetLine2(TypInputFile * input)
if (input->sline == 0 ||
(IS_STRING_REP(input->sline) &&
GET_LEN_STRING(input->sline) <= input->spos)) {
input->sline = CALL_1ARGS( ReadLineFunc, input->stream );
// If we are in the process of quitting, we cannot call
// GAP functions, so we just return EOF.
if (STATE(UserHasQuit) || STATE(UserHasQUIT)) {
input->sline = Fail;
}
else {
input->sline = CALL_1ARGS(ReadLineFunc, input->stream);
}
input->spos = 0;
}
if ( input->sline == Fail || ! IS_STRING(input->sline) ) {
Expand Down
2 changes: 2 additions & 0 deletions tst/testspecial/error-in-InputTextString.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
READ_NORECOVERY(InputTextString("Print(1 + [()]);"));
quit;
9 changes: 9 additions & 0 deletions tst/testspecial/error-in-InputTextString.g.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
gap> READ_NORECOVERY(InputTextString("Print(1 + [()]);"));
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `+' on 2 arguments at GAPROOT/lib/methsel2.g:LINE called from
<function "HANDLE_METHOD_NOT_FOUND">( <arguments> )
called from read-eval loop at stream:1
type 'quit;' to quit to outer loop
brk> quit;
fail
gap> QUIT;
1 change: 1 addition & 0 deletions tst/testspecial/exit-in-InputTextString.g
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
READ_NORECOVERY(InputTextString("Print(QuitGap(0));"));
1 change: 1 addition & 0 deletions tst/testspecial/exit-in-InputTextString.g.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gap> READ_NORECOVERY(InputTextString("Print(QuitGap(0));"));

0 comments on commit f552fac

Please sign in to comment.