Skip to content

Commit 85e8f9e

Browse files
authored
Disarm timer in runguard after child has exited. (#2157)
If we would not disarm the timer, there is a possibility that the timer sends us a SIGALRM while we are still busy with cleaning the sandbox up. What you observe in these cases is a judging with wall time well below the time limit is judged as TLE, e.g. ``` Timelimit exceeded. runtime: 0.288s cpu, 0.302s wall memory used: 26066944 bytes ********** runguard stderr follows ********** /opt/domjudge/bin/runguard: warning: timelimit exceeded (hard wall time): aborting command ``` In practice, we saw the behavior happening when running many judgedaemons and domserver on a single machine while rejudging the whole contest (i.e. under quite high load). In that case, the call `cgroup_delete_cgroup_ext` did sometimes hang for multiple seconds. For easy reproducibility, you can also add an artificial delay in the clean up code, e.g. by adding something like: ``` const struct timespec artificial_delay = { 10, 0 }; nanosleep(&artificial_delay, NULL); ```
1 parent 0c5bf5e commit 85e8f9e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

judge/runguard.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,8 +1428,23 @@ int main(int argc, char **argv)
14281428
} else {
14291429
exitcode = WEXITSTATUS(status);
14301430
}
1431+
verbose("child exited with exit code %d", exitcode);
14311432

1432-
check_remaining_procs();
1433+
if ( use_walltime ) {
1434+
/* Disarm timer we set previously so if any of the
1435+
* clean-up steps below are slow we are not mistaking
1436+
* this for a wall-time timeout. */
1437+
itimer.it_interval.tv_sec = 0;
1438+
itimer.it_interval.tv_usec = 0;
1439+
itimer.it_value.tv_sec = 0;
1440+
itimer.it_value.tv_usec = 0;
1441+
1442+
if ( setitimer(ITIMER_REAL,&itimer,NULL)!=0 ) {
1443+
error(errno,"disarming timer");
1444+
}
1445+
}
1446+
1447+
check_remaining_procs();
14331448

14341449
double cputime = -1;
14351450
output_cgroup_stats(&cputime);

0 commit comments

Comments
 (0)