Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions data/solutions/compile-error.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

int solve() {
vector<pair<int, string>> pairs;
int a, b, c;
cin >> a >> b >> c;
cout << a / 0 << endl;
pairs.push_back(make_pair(a, "Alvin"));
pairs.push_back(make_pair(b, "Berto"));
pairs.push_back(make_pair(c, "Carlo"));
sort(pairs.begin(), pairs.end());
cout << pairs[2].second << endl;
}

int main() {
solve2();
}
7 changes: 7 additions & 0 deletions data/solutions/runtime-error.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>
#include <assert.h>

int main() {
assert(5 > 5);
printf("Done\n");
}
5 changes: 5 additions & 0 deletions data/solutions/wrong-answer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>

int main() {
printf("Wrong answer!!!111!\n");
}
4 changes: 4 additions & 0 deletions src/common/utils/guards.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export function notNull<T>(x: T | null): x is T {
return x != null;
}

export function isInteger(str: string): boolean {
return /^\d+$/.test(str);
}
8 changes: 7 additions & 1 deletion src/server/evaluation/judge_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "fs";
import ChildProcess from "child_process";
import { Verdict } from "common/types/constants";
import { ContestantScript, JudgeTaskBatch, JudgeTaskCommunication } from "common/types/judge";
import { isInteger } from "common/utils/guards";
import { IsolateResult } from "./types";
import { LANGUAGE_SPECS } from "./judge_compile";
import {
Expand All @@ -14,6 +15,7 @@ import {

export const ISOLATE_BIN = "/usr/local/bin/isolate";
const ISOLATE_DIRECTORY = "/var/local/lib/isolate";
const SIGSEGV = 11; // Signal number for segmentation fault

export type IsolateInstance = {
name: string;
Expand Down Expand Up @@ -91,7 +93,11 @@ export class IsolateUtils {
} else if (status === "RE") {
result.verdict = Verdict.RuntimeError;
} else if (status === "SG") {
result.verdict = Verdict.MemoryLimitExceeded;
if (exitsig != null && isInteger(exitsig) && +exitsig === SIGSEGV) {
result.verdict = Verdict.MemoryLimitExceeded;
} else {
result.verdict = Verdict.RuntimeError;
}
} else if (exitcode === "0") {
result.verdict = Verdict.Accepted;
}
Expand Down