ioi / isolate

Sandbox for securely executing untrusted programs
Other
1.1k stars 161 forks source link

Extra Time option being ignored #95

Closed jaideep-cn closed 2 years ago

jaideep-cn commented 4 years ago

I am trying to run a simple python script using isolate inside a docker container. Here is the python code:

test.py

flag = 1
while(True):
    flag = flag + 1

Here are the isolate commands I am using:

BOX_ID=1231221312
ISOLATE_PATH=`isolate --cg -b $BOX_ID --init`
ISOLATE_BOX_PATH="$ISOLATE_PATH/box/"
ISOLATE_META_FILE_PATH="$ISOLATE_BOX_PATH/meta"
RUN_CMD="/usr/bin/python3 test.py"
MEMLIMIT=256000
TIMELIMIT=4
EXTRA_TIME=3
WALL_LIMIT=15
isolate --cg --cg-timing -b $BOX_ID -o out.txt -r err -M $ISOLATE_META_FILE_PATH -t $TIMELIMIT -x $EXTRA_TIME  -w $WALL_LIMIT -p --dir=/etc --cg-mem $MEMLIMIT -E HOME=$ISOLATE_PATH --run -- $RUN_CMD

Here is the isolate meta result file:

Screenshot 2020-09-10 at 12 24 55 PM

Here is my isolate --version output:

Screenshot 2020-09-10 at 12 27 56 PM

What I can't understand is that why isn't the program being killed after 7 seconds (3 seconds beyond the time limit)? Am I missing something here? I have tried running it without all the CG options.

ilian98 commented 3 years ago

One college and I just noticed today that our configuration with extra-time didn't work as expected, just like yours. It turned out that the documentation about the extra-time wasn't clear enough. The extra-time is the TOTAL time (normal time limit + bonus time) for the work of the program. So in your case if you want it to work for maximum 4 seconds but wait until 7 seconds, you should set: -x 7 in the options.

gollux commented 2 years ago

Sorry, it was documented in a rather confusing way. Fixed the documentation.