commit 05d6aca373fa1415ccd4db7cf12f2715a27567d4
parent 39aeac7e72886bff7385d8777ed78f504325e44c
Author: Andrew Laack <andrew@laack.co>
Date: Fri, 13 Nov 2026 20:49:04 -0600
Limit mem swap usage, and add timeouts
Diffstat:
5 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/assets/problems/000001/problem.html b/assets/problems/000001/problem.html
@@ -1,6 +1,6 @@
<p>
-Time limit per test: 3 seconds
+Time limit per test: 2 seconds
Memory limit per test: 256 megabytes
There are buildings in front of you with heights [a_0,a_1,...,a_{n-1}], where a_i is an integer. Assume each building has a depth of 100 units, there is a 10 unit gap between each of them, they are all directly in front of you, and the ground is flat.
diff --git a/containers/entrypoint.sh b/containers/entrypoint.sh
@@ -16,5 +16,6 @@ INPUTS=$(ls /inputs)
for INPUT in $INPUTS; do
BASE=${INPUT%.*}
- cat /inputs/$INPUT | /tmp/submission.out > /outputs/$BASE.out
+ cat /inputs/$INPUT | timeout 2 /tmp/submission.out > /outputs/$BASE.out
+ echo $? > /outputs/$BASE.code
done
diff --git a/main.ml b/main.ml
@@ -0,0 +1,4 @@
+let () =
+ let rec forever idx =
+ forever 0
+ in forever 0
diff --git a/ojudge/bin/judge.ml b/ojudge/bin/judge.ml
@@ -1,4 +1,4 @@
-let command = "timeout 50 podman run --rm -v ./code:/code:ro -v ./inputs:/inputs:ro -v ./outputs:/outputs:rw --network=none --memory=256MB --cpus 1 judge"
+let command = "timeout 50 podman run --rm -v ./code:/code:ro -v ./inputs:/inputs:ro -v ./outputs:/outputs:rw --network=none --memory=256MB --memory-swap=256MB --cpus 1 judge"
let getOldestPending () =
let pending = "/var/lib/ojudge/pending-review" in
@@ -32,10 +32,18 @@ let writeResults dir code =
List.sort compare (Array.to_list (Sys.readdir (dir ^ "/expected"))) in
let verdict name =
let actual = dir ^ "/outputs/" ^ name in
- if not (Sys.file_exists actual) then "MISSING"
+ let code =
+ try int_of_string (String.trim (readFile
+ (dir ^ "/outputs/" ^ Filename.remove_extension name ^ ".code")))
+ with _ -> 0 in
+ if code = 124 then "TIME LIMIT EXCEEDED"
+ else if code = 137 then "MEMORY LIMIT EXCEEDED"
+ else if code <> 0 then "RUNTIME ERROR"
+ else if not (Sys.file_exists actual) then "MISSING"
else if String.trim (readFile actual)
= String.trim (readFile (dir ^ "/expected/" ^ name)) then "PASS"
- else "WRONG" in
+ else "WRONG"
+ in
let lines = List.map (fun n -> (Filename.remove_extension n, verdict n)) names in
let passed = List.length (List.filter (fun (_, v) -> v = "PASS") lines) in
Out_channel.with_open_text (dir ^ "/results/results.txt") (fun oc ->
diff --git a/ojudge/bin/submissions.ml b/ojudge/bin/submissions.ml
@@ -9,12 +9,6 @@ let copyDir src dst =
if not (Sys.is_directory s) then copyFile s (Filename.concat dst name))
(Sys.readdir src)
-let valid_id s =
- s <> ""
- && String.for_all
- (function '0'..'9'-> true | _ -> false)
- s
-
let () = ignore (Unix.umask 0o002)
let rec mkdir d =