def update_feedback(self, check, error, process, result): result.feedback = ( check.feedback or (process.feedback if hasattr(process, 'feedback') else getattr( self.binary, 'get_feedback', lambda x, y, z: '')(error, result, process))) if not result.feedback and result.get_main_code() == Result.RTE: if hasattr(process, 'was_initialized') and not process.was_initialized: # Process may failed to initialize, resulting in a SIGKILL without any prior signals. # See <https://github.com/DMOJ/judge/issues/179> for more details. result.feedback = 'failed initializing' elif hasattr(process, 'signal'): # I suppose generate a SIGKILL message is better when we don't know the signal that caused it. result.feedback = strsignal( process.signal).lower() if process.signal else 'killed' # On Linux we can provide better help messages if hasattr(process, 'protection_fault') and process.protection_fault: syscall, callname, args = process.protection_fault print_protection_fault(process.protection_fault) callname = callname.replace('sys_', '', 1) message = { 'open': 'opening files is not allowed', }.get(callname, '%s syscall disallowed' % callname) result.feedback = message
def grade(self, case): result = Result(case) case.input_data() # cache generator data self._current_proc = self.binary.launch(time=self.problem.time_limit, memory=self.problem.memory_limit, pipe_stderr=True, unbuffered=case.config.unbuffered) error = self._interact_with_process(case, result) process = self._current_proc result.max_memory = process.max_memory or 0.0 result.execution_time = process.execution_time or 0.0 result.r_execution_time = process.r_execution_time or 0.0 # checkers might crash if any data is None, so force at least empty string check = case.checker()(result.proc_output or '', case.output_data() or '', submission_source=self.source, judge_input=case.input_data() or '', point_value=case.points) # checkers must either return a boolean (True: full points, False: 0 points) # or a CheckerResult, so convert to CheckerResult if it returned bool if not isinstance(check, CheckerResult): check = CheckerResult(check, case.points if check else 0.0) result.result_flag |= [Result.WA, Result.AC][check.passed] # Translate status codes/process results into Result object for status codes if process.returncode > 0: # print>> sys.stderr, 'Exited with error: %d' % process.returncode result.result_flag |= Result.IR if process.returncode < 0: # None < 0 == True # if process.returncode is not None: # print>> sys.stderr, 'Killed by signal %d' % -process.returncode result.result_flag |= Result.RTE # Killed by signal if process.tle: result.result_flag |= Result.TLE if process.mle: result.result_flag |= Result.MLE if result.result_flag & ~Result.WA: check.points = 0 result.points = check.points result.feedback = (check.feedback or (process.feedback if hasattr(process, 'feedback') else getattr(self.binary, 'get_feedback', lambda x, y: '')(error, result))) if not result.feedback and hasattr(process, 'signal') and process.signal and result.get_main_code() in [Result.IR, Result.RTE]: result.feedback = strsignal(process.signal) return result
def update_feedback(self, check, error, process, result): result.feedback = (check.feedback or (process.feedback if hasattr(process, 'feedback') else getattr(self.binary, 'get_feedback', lambda x, y, z: '')(error, result, process))) if not result.feedback and hasattr(process, 'signal') and process.signal and result.get_main_code() == Result.RTE: result.feedback = strsignal(process.signal) # On Linux we can provide better help messages if hasattr(process, 'protection_fault') and process.protection_fault: sigid, callname = process.protection_fault callname = callname.replace('sys_', '', 1) message = { 'open': 'opening files is not allowed', 'socketcall': 'accessing the network is not allowed', 'socket': 'accessing the network is not allowed', 'clone': 'threading is not allowed' }.get(callname, '%s syscall disallowed' % callname) result.feedback = message
def update_feedback(self, check, error, process, result): result.feedback = (check.feedback or (process.feedback if hasattr(process, 'feedback') else getattr(self.binary, 'get_feedback', lambda x, y, z: '')(error, result, process))) if not result.feedback and result.get_main_code() == Result.RTE: if hasattr(process, 'was_initialized') and not process.was_initialized: # Process may failed to initialize, resulting in a SIGKILL without any prior signals. # See <https://github.com/DMOJ/judge/issues/179> for more details. result.feedback = 'failed initializing' elif hasattr(process, 'signal'): # I suppose generate a SIGKILL message is better when we don't know the signal that caused it. result.feedback = strsignal(process.signal).lower() if process.signal else 'killed' # On Linux we can provide better help messages if hasattr(process, 'protection_fault') and process.protection_fault: syscall, callname, args = process.protection_fault print_protection_fault(process.protection_fault) callname = callname.replace('sys_', '', 1) message = '%s syscall disallowed' % callname result.feedback = message
def grade(self, case): result = Result(case) case.input_data() # cache generator data self._current_proc = self.binary.launch( time=self.problem.time_limit, memory=self.problem.memory_limit, pipe_stderr=True, unbuffered=case.config.unbuffered) error = self._interact_with_process(case, result) process = self._current_proc result.max_memory = process.max_memory or 0.0 result.execution_time = process.execution_time or 0.0 result.r_execution_time = process.r_execution_time or 0.0 # checkers might crash if any data is None, so force at least empty string check = case.checker()(result.proc_output or '', case.output_data() or '', submission_source=self.source, judge_input=case.input_data() or '', point_value=case.points) # checkers must either return a boolean (True: full points, False: 0 points) # or a CheckerResult, so convert to CheckerResult if it returned bool if not isinstance(check, CheckerResult): check = CheckerResult(check, case.points if check else 0.0) result.result_flag |= [Result.WA, Result.AC][check.passed] # Translate status codes/process results into Result object for status codes if process.returncode > 0: # print>> sys.stderr, 'Exited with error: %d' % process.returncode result.result_flag |= Result.IR if process.returncode < 0: # None < 0 == True # if process.returncode is not None: # print>> sys.stderr, 'Killed by signal %d' % -process.returncode result.result_flag |= Result.RTE # Killed by signal if process.tle: result.result_flag |= Result.TLE if process.mle: result.result_flag |= Result.MLE if result.result_flag & ~Result.WA: check.points = 0 result.points = check.points result.feedback = ( check.feedback or (process.feedback if hasattr(process, 'feedback') else getattr( self.binary, 'get_feedback', lambda x, y: '')(error, result))) if not result.feedback and hasattr( process, 'signal') and process.signal and result.get_main_code() in [ Result.IR, Result.RTE ]: result.feedback = strsignal(process.signal) return result