@@ -343,6 +343,15 @@ public function run(): void
343343 $ this ->loop ();
344344 }
345345
346+ private function handleProgramInternalError (int $ judgetaskid , array $ metadata ): void
347+ {
348+ // Unexpected situation during setup of the submission, so disable the judgehost itself as no
349+ // submission should be able to break runguard
350+ // TODO: Add suggestion for what to do in case this submission breaks for all judgehosts, violating above statement
351+ // would we advice ignoring the submission or changing the database etc.
352+ $ this ->disable ('judgehost ' , 'hostname ' , $ this ->myhost , "Running submission caused a crash/error in runguard: " . $ metadata ['internal-error ' ], $ judgetaskid );
353+ }
354+
346355 private function initialize (): void
347356 {
348357 // Set umask to allow group and other access, as this is needed for the
@@ -1724,7 +1733,8 @@ private function testcaseRunInternal(
17241733 $ compare_runpath ,
17251734 $ compare_args ,
17261735 array $ run_config ,
1727- array $ compare_config
1736+ array $ compare_config ,
1737+ ?int $ judgetaskid = null
17281738 ) : Verdict {
17291739 // Record some state so that we can properly reset it later in the finally block
17301740 $ oldCwd = getcwd ();
@@ -2038,6 +2048,10 @@ private function testcaseRunInternal(
20382048 }
20392049 logmsg (LOG_DEBUG , "checking program exit status " );
20402050 $ program_meta_ini = $ this ->readMetadata ('program.meta ' );
2051+ if (isset ($ program_meta_ini ['internal-error ' ])) {
2052+ $ this ->handleProgramInternalError ($ judgetaskid , $ program_meta_ini );
2053+ return Verdict::INTERNAL_ERROR ;
2054+ }
20412055 logmsg (LOG_DEBUG , "parsed program meta: " . var_export ($ program_meta_ini , true ));
20422056 $ resourceInfo = "\nruntime: "
20432057 . $ program_meta_ini ['cpu-time ' ] . 's cpu, '
@@ -2239,14 +2253,24 @@ private function runTestcase(
22392253 $ compare_runpath ,
22402254 $ compare_config ['compare_args ' ],
22412255 $ run_config ,
2242- $ compare_config
2256+ $ compare_config ,
2257+ $ judgeTask ['judgetaskid ' ]
22432258 );
22442259
22452260 $ result = str_replace ('_ ' , '- ' , strtolower ($ verdict ->name ));
2261+ if ($ result === 'internal-error ' ) {
2262+ // Don't disable anything as it's unclear how problematic the error is
2263+ return false ;
2264+ }
22462265
22472266 // Try to read metadata from file
22482267 $ runtime = null ;
22492268 $ metadata = $ this ->readMetadata ($ passdir . '/program.meta ' );
2269+ if (isset ($ metadata ['internal-error ' ])) {
2270+ // This should already be handled in `testcaseRunInternal`
2271+ $ this ->handleProgramInternalError ($ judgetaskid , $ metadata );
2272+ return false ;
2273+ }
22502274
22512275 if (isset ($ metadata ['time-used ' ]) && array_key_exists ($ metadata ['time-used ' ], $ metadata )) {
22522276 $ runtime = $ metadata [$ metadata ['time-used ' ]];
0 commit comments