Skip to content

Commit 59d4dfd

Browse files
committed
Handle internal-errors in compare.meta
Left https://github.com/DOMjudge/domjudge/blob/main/judge/judgedaemon.main.php#L2256 as is as it is only used in case we already disable the judgehost. We could get missing keys here though.
1 parent dab1ad6 commit 59d4dfd

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

judge/judgedaemon.main.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function run(): void
343343
$this->loop();
344344
}
345345

346-
private function handleProgramInternalError(int $judgetaskid, array $metadata): void
346+
private function handleMetaInternalError(int $judgetaskid, array $metadata): void
347347
{
348348
// Unexpected situation during setup of the submission, so disable the judgehost itself as no
349349
// submission should be able to break runguard
@@ -2024,10 +2024,14 @@ private function testcaseRunInternal(
20242024
}
20252025

20262026
logmsg(LOG_DEBUG, "checking compare script exit status: $exitcode");
2027-
$compare_meta_raw = file_get_contents("compare.meta");
20282027
$compare_tmp = is_readable("compare.tmp") ? file_get_contents("compare.tmp") : "";
2029-
$compareTimedOut = (bool)preg_match('/time-result: .*timelimit/', $compare_meta_raw);
2030-
if ($compareTimedOut) {
2028+
$compare_meta_ini = $this->readMetadata('compare.meta');
2029+
$compareTimedOut = false;
2030+
if (isset($compare_meta_ini['internal-error'])) {
2031+
$this->handleMetaInternalError($description, $judgetaskid, $compare_meta_ini);
2032+
return Verdict::INTERNAL_ERROR;
2033+
} elseif ($compare_meta_ini['time-result'] === 'timelimit') {
2034+
$compareTimedOut = true;
20312035
logmsg(LOG_ERR, "Comparing aborted after the script timelimit of %s seconds, compare script output:\n%s", $scripttimelimit, $compare_tmp);
20322036
}
20332037

@@ -2049,7 +2053,7 @@ private function testcaseRunInternal(
20492053
logmsg(LOG_DEBUG, "checking program exit status");
20502054
$program_meta_ini = $this->readMetadata('program.meta');
20512055
if (isset($program_meta_ini['internal-error'])) {
2052-
$this->handleProgramInternalError($description, $judgetaskid, $program_meta_ini);
2056+
$this->handleMetaInternalError($description, $judgetaskid, $program_meta_ini);
20532057
return Verdict::INTERNAL_ERROR;
20542058
}
20552059
logmsg(LOG_DEBUG, "parsed program meta: " . var_export($program_meta_ini, true));
@@ -2058,7 +2062,6 @@ private function testcaseRunInternal(
20582062
. $program_meta_ini['wall-time'] . "s wall\n"
20592063
. 'memory: ' . $program_meta_ini['memory-bytes'] . ' bytes';
20602064

2061-
$compare_meta_ini = $this->readMetadata('compare.meta');
20622065
logmsg(LOG_DEBUG, "parsed compare meta: " . var_export($compare_meta_ini, true));
20632066

20642067
$programOutSize = filesize("program.out");
@@ -2268,7 +2271,7 @@ private function runTestcase(
22682271
$metadata = $this->readMetadata($passdir . '/program.meta');
22692272
if (isset($program_meta_ini['internal-error'])) {
22702273
// This should already be handled in `testcaseRunInternal`
2271-
$this->handleProgramInternalError($judgetaskid, $program_meta_ini);
2274+
$this->handleMetaInternalError($judgetaskid, $program_meta_ini);
22722275
return false;
22732276
}
22742277

0 commit comments

Comments
 (0)