Skip to content

Commit

Permalink
Remove the timeout code
Browse files Browse the repository at this point in the history
It had fundamental problems which seem unlikely to be resolved.
See also issues #664, #695, #765.
  • Loading branch information
fingolfin committed May 19, 2017
1 parent 5612f27 commit f019951
Show file tree
Hide file tree
Showing 23 changed files with 4 additions and 756 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ build_script:
- bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./etc/ci-prepare.sh"

test_script:
- bash -lc "rm $APPVEYOR_BUILD_FOLDER/tst/testinstall/timeout.tst" # HACK
- bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./etc/ci.sh"

on_success:
Expand Down
1 change: 0 additions & 1 deletion Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ SOURCES += src/streams.c
SOURCES += src/stringobj.c
SOURCES += src/sysfiles.c
SOURCES += src/system.c
SOURCES += src/systimers.c
SOURCES += src/tietze.c
SOURCES += src/trans.c
SOURCES += src/vars.c
Expand Down
5 changes: 1 addition & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,7 @@ AC_SEARCH_LIBS([dlopen], [dl],
dnl check for timing functions
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_FUNCS([getrusage gettimeofday clock_gettime clock_getres])
AC_CHECK_FUNCS([setitimer getitimer])
AC_CHECK_LIB([rt], [timer_create])
AC_CHECK_FUNCS([timer_settime timer_gettime timer_create])
AC_CHECK_FUNCS([sys_timer_settime sys_timer_gettime sys_timer_create])
AC_CHECK_FUNCS([setitimer])

dnl check for functions dealing with virtual memory
AC_CHECK_FUNCS([vm_allocate sbrk madvise sysconf])
Expand Down
11 changes: 0 additions & 11 deletions doc/ref/function.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ several arguments</Heading>

</Section>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Calling a function with a time limit">
<Heading>Calling a function with a time limit</Heading>


<#Include Label="CallWithTimeout">
<#Include Label="GAPInfo.TimeoutsSupported">
</Section>




<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Functions that do nothing">
Expand Down
1 change: 0 additions & 1 deletion doc/ref/makedocreldata.g
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ GAPInfo.ManualDataRef:= rec(
"../../lib/fpmon.gd",
"../../lib/fpsemi.gd",
"../../lib/function.g",
"../../lib/function.gd",
"../../lib/galois.gd",
"../../lib/gasman.gd",
"../../lib/ghom.gd",
Expand Down
6 changes: 1 addition & 5 deletions hpcgap/lib/error.g
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ Unbind(ErrorInner);
BIND_GLOBAL("ErrorInner",
function( arg )
local context, mayReturnVoid, mayReturnObj, lateMessage, earlyMessage,
x, prompt, res, errorLVars, justQuit, printThisStatement, timeout,
x, prompt, res, errorLVars, justQuit, printThisStatement,
location;

timeout := STOP_TIMEOUT();
context := arg[1].context;
if not IsLVarsBag(context) then
PrintTo("*errout*", "ErrorInner: option context must be a local variables bag\n");
Expand Down Expand Up @@ -267,9 +266,6 @@ BIND_GLOBAL("ErrorInner",
fi;
JUMP_TO_CATCH(3);
fi;
if timeout <> fail then
RESUME_TIMEOUT(timeout);
fi;
if Length(res) > 0 then
return res[1];
else
Expand Down
3 changes: 0 additions & 3 deletions hpcgap/lib/read3.g
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,5 @@ ReadLib("proto.gd");

ReadLib("gasman.gd");

# files dealing with function calling
ReadLib("function.gd");

# random sources
ReadLib("random.gi");
17 changes: 0 additions & 17 deletions hpcgap/lib/system.g
Original file line number Diff line number Diff line change
Expand Up @@ -520,23 +520,6 @@ BIND_GLOBAL("ARCH_IS_UNIX",function()
return not ARCH_IS_WINDOWS();
end);

#############################################################################
##
#V GAPInfo.TimeoutsSupported
##
## <#GAPDoc Label="GAPInfo.TimeoutsSupported">
## <ManSection>
## <Var Name="GAPInfo.TimeoutsSupported"/>
##
## <Description>
## tests whether this installation of &GAP; supports the timeout functionality
## of <Ref Func="CallWithTimeout"/> and related functions.
## </Description>
## </ManSection>
## <#/GAPDoc>

GAPInfo.TimeoutsSupported := TIMEOUTS_SUPPORTED();

#############################################################################
##
#V GAPInfo.InitFiles
Expand Down
18 changes: 0 additions & 18 deletions hpcgap/src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1676,19 +1676,6 @@ sig_atomic_t volatile RealExecStatCopied;
int volatile RealExecStatCopied;
#endif

/****************************************************************************
**
*F void CheckAndRespondToAlarm()
**
*/

static void CheckAndRespondToAlarm(void) {
if ( SyAlarmHasGoneOff ) {
assert(NumAlarmJumpBuffers);
syLongjmp(&(AlarmJumpBuffers[--NumAlarmJumpBuffers]),1);
}
}

/****************************************************************************
**
*F UInt TakeInterrupt() . . . . . . . . allow user interrupts
Expand All @@ -1707,7 +1694,6 @@ UInt TakeInterrupt( void ) {
if (STATE(CurrExecStatFuncs) == IntrExecStatFuncs) {
assert(STATE(CurrExecStatFuncs) != ExecStatFuncs);
STATE(CurrExecStatFuncs) = ExecStatFuncs;
CheckAndRespondToAlarm();
ErrorReturnVoid( "user interrupt", 0L, 0L, "you can 'return;'" );
return 1;
}
Expand All @@ -1732,10 +1718,6 @@ UInt ExecIntrStat (
/* change the entries in 'ExecStatFuncs' back to the original */
STATE(CurrExecStatFuncs) = ExecStatFuncs;

/* One reason we might be here is a timeout. If so longjump out to the
CallWithTimeLimit where we started */
CheckAndRespondToAlarm();

/* and now for something completely different */
HandleInterrupts(1, stat);

Expand Down
23 changes: 0 additions & 23 deletions hpcgap/tst/testinstall/timeout.tst

This file was deleted.

6 changes: 1 addition & 5 deletions lib/error.g
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,9 @@ Unbind(ErrorInner);
BIND_GLOBAL("ErrorInner",
function( arg )
local context, mayReturnVoid, mayReturnObj, lateMessage, earlyMessage,
x, prompt, res, errorLVars, justQuit, printThisStatement, timeout,
x, prompt, res, errorLVars, justQuit, printThisStatement,
location;

timeout := STOP_TIMEOUT();
context := arg[1].context;
if not IsLVarsBag(context) then
PrintTo("*errout*", "ErrorInner: option context must be a local variables bag\n");
Expand Down Expand Up @@ -255,9 +254,6 @@ BIND_GLOBAL("ErrorInner",
fi;
JUMP_TO_CATCH(3);
fi;
if timeout <> fail then
RESUME_TIMEOUT(timeout);
fi;
if Length(res) > 0 then
return res[1];
else
Expand Down
76 changes: 0 additions & 76 deletions lib/function.gd

This file was deleted.

67 changes: 1 addition & 66 deletions lib/function.gi
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,11 @@
##
#Y Copyright (C) 2015 The GAP Group
##
## This file contains the implementations of the functions and operations
## This file contains the implementations of the functions and operations
## relating to functions and function-calling which are not so basic
## that they need to be in function.g
##


#############################################################################
##
#F CallWithTimeout( <timeout>, <func>[, <arg1>[, <arg2>....]] )
## . . call a function with a time limit
#F CallWithTimeoutList( <timeout>, <func>, <arglist> )
##
##

InstallGlobalFunction(CallWithTimeout,
function( timeout, func, arg... )
return CallWithTimeoutList(timeout, func, arg);
end );

InstallGlobalFunction("CallWithTimeoutList",
function(timeout, func, arglist )
local process, nano, seconds, microseconds;
process := function(name, scale)
local val;
if IsBound(timeout.(name)) then
val := timeout.(name);
if IsRat(val) or IsFloat(val) then
nano := nano + Int(val*scale);
else
Error("CallWithTimeout[List]: can't understand period of ",val," ",name,". Ignoring.");
fi;
fi;
end;
if not GAPInfo.TimeoutsSupported then
Error("Calling with time limits not supported in this GAP installation");
return fail;
fi;
if IsInt(timeout) then
nano := 1000*timeout;
else
if not IsRecord(timeout) then
Error("CallWithTimeout[List]: timeout must be an integer or record");
return fail;
fi;
nano := 0;
process("nanoseconds",1);
process("microseconds",1000);
process("milliseconds",1000000);
process("seconds",10^9);
process("minutes",60*10^9);
process("hours",3600*10^9);
process("days",24*3600*10^9);
process("weeks",7*24*3600*10^9);
fi;
if nano < 0 then
Error("Negative timeout is not permitted");
return fail;
fi;
seconds := QuoInt(nano, 10^9);
microseconds := QuoInt(nano mod 10^9, 1000);
if seconds = 0 and microseconds = 0 then
# zero or tiny timeout. just simulate timeout now
return fail;
fi;
# make sure it's a small int. Cap timeouts at about 8 years on
# 32 bit systems
seconds := Minimum(seconds,2^(8*GAPInfo.BytesPerVariable-4)-1);
return CALL_WITH_TIMEOUT(seconds, microseconds, func, arglist);
end);

InstallMethod( ViewString, "for a function", true, [IsFunction], 0,
function(func)
local locks, nams, narg, i, isvarg, result;
Expand Down
3 changes: 0 additions & 3 deletions lib/read3.g
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,5 @@ ReadLib("gasman.gd");

ReadLib("memusage.gd");

# files dealing with function calling
ReadLib("function.gd");

# random sources
ReadLib("random.gi");
17 changes: 0 additions & 17 deletions lib/system.g
Original file line number Diff line number Diff line change
Expand Up @@ -514,23 +514,6 @@ BIND_GLOBAL("ARCH_IS_UNIX",function()
return not ARCH_IS_WINDOWS();
end);

#############################################################################
##
#V GAPInfo.TimeoutsSupported
##
## <#GAPDoc Label="GAPInfo.TimeoutsSupported">
## <ManSection>
## <Var Name="GAPInfo.TimeoutsSupported"/>
##
## <Description>
## tests whether this installation of &GAP; supports the timeout functionality
## of <Ref Func="CallWithTimeout"/> and related functions.
## </Description>
## </ManSection>
## <#/GAPDoc>

GAPInfo.TimeoutsSupported := TIMEOUTS_SUPPORTED();

#############################################################################
##
#V GAPInfo.InitFiles
Expand Down
Loading

0 comments on commit f019951

Please sign in to comment.