Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,15 @@ public function run(): void
$this->loop();
}

private function handleProgramInternalError(int $judgetaskid, array $metadata): void
{
// Unexpected situation during setup of the submission, so disable the judgehost itself as no
// submission should be able to break runguard
// TODO: Add suggestion for what to do in case this submission breaks for all judgehosts, violating above statement
// would we advice ignoring the submission or changing the database etc.
$this->disable('judgehost', 'hostname', $this->myhost, "Running submission caused a crash/error in runguard: " . $metadata['internal-error'], $judgetaskid);
}

private function initialize(): void
{
// Set umask to allow group and other access, as this is needed for the
Expand Down Expand Up @@ -1724,7 +1733,8 @@ private function testcaseRunInternal(
$compare_runpath,
$compare_args,
array $run_config,
array $compare_config
array $compare_config,
?int $judgetaskid = null
) : Verdict {
// Record some state so that we can properly reset it later in the finally block
$oldCwd = getcwd();
Expand Down Expand Up @@ -1779,7 +1789,7 @@ private function testcaseRunInternal(

foreach ([
'system.out', # Judging system output (info/debug/error)
'program.out', 'program.err', # Program output and stderr (for extra information)
'program.out', 'program.err', # Program output and stderr (for extra information)
'program.meta', 'runguard.err', # Metadata and runguard stderr
'compare.meta', 'compare.err' # Compare runguard metadata and stderr
] as $file) {
Expand Down Expand Up @@ -2038,6 +2048,10 @@ private function testcaseRunInternal(
}
logmsg(LOG_DEBUG, "checking program exit status");
$program_meta_ini = $this->readMetadata('program.meta');
if (isset($program_meta_ini['internal-error'])) {
$this->handleProgramInternalError($judgetaskid, $program_meta_ini);
return Verdict::INTERNAL_ERROR;
}
logmsg(LOG_DEBUG, "parsed program meta: " . var_export($program_meta_ini, true));
$resourceInfo = "\nruntime: "
. $program_meta_ini['cpu-time'] . 's cpu, '
Expand Down Expand Up @@ -2239,14 +2253,24 @@ private function runTestcase(
$compare_runpath,
$compare_config['compare_args'],
$run_config,
$compare_config
$compare_config,
$judgeTask['judgetaskid']
);

$result = str_replace('_', '-', strtolower($verdict->name));
if ($result === 'internal-error') {
// Don't disable anything as it's unclear how problematic the error is
return false;
}

// Try to read metadata from file
$runtime = null;
$metadata = $this->readMetadata($passdir . '/program.meta');
if (isset($metadata['internal-error'])) {
// This should already be handled in `testcaseRunInternal`
$this->handleProgramInternalError($judgetaskid, $metadata);
return false;
}

if (isset($metadata['time-used']) && array_key_exists($metadata['time-used'], $metadata)) {
$runtime = $metadata[$metadata['time-used']];
Expand Down
Loading