Skip to content

Commit 772aee2

Browse files
committed
judge/sandbox: fix incorrect placeholder for static linking
The C compilation command used an incorrect placeholder to denote static linking (`%static` instead of `%STATIC%`). I also added two debugging statements to print the compilation and sandboxing commands in the sandbox judge.
1 parent 3c62a98 commit 772aee2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

judge/sandbox/lib.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
class judge_sandbox extends judge_base {
5555
protected static $supported_languages = array(
5656
'c' => 'gcc -D_MOODLE_ONLINE_JUDGE_ %WALL% %STATIC% -o %DEST% %SOURCES% %LM%',
57-
'c_warn2err' => 'gcc -D_MOODLE_ONLINE_JUDGE_ %WALL% -Werror %static% -o %DEST% %SOURCES% %LM%',
57+
'c_warn2err' => 'gcc -D_MOODLE_ONLINE_JUDGE_ %WALL% -Werror %STATIC% -o %DEST% %SOURCES% %LM%',
5858
'cpp' => 'g++ -D_MOODLE_ONLINE_JUDGE_ %WALL% %STATIC% -o %DEST% %SOURCES% %LM%',
5959
'cpp_warn2err' => 'g++ -D_MOODLE_ONLINE_JUDGE_ %WALL% -Werror %STATIC% -o %DEST% %SOURCES% %LM%');
6060

@@ -156,6 +156,7 @@ protected function compile($files) {
156156
// run compiler and redirect stderr to stdout
157157
$output = array();
158158
$return = 0;
159+
echo("Compilation command: $command\n");
159160
exec($command . ' 2>&1', $output, $return);
160161
$arr = array();
161162
foreach ($output as $value) {
@@ -187,6 +188,7 @@ protected function run_in_sandbox($binfile) {
187188

188189
$sand .= ' -l cpu=' . escapeshellarg(($this->task->cpulimit) * 1000) . ' -l memory=' . escapeshellarg($this->task->memlimit) . ' -l disk=512000 ' . escapeshellarg($binfile);
189190

191+
echo("Sandboxing command: $sand\n");
190192
// run it in sandbox!
191193
$descriptorspec = array(0 => array('pipe', 'r'), // stdin is a pipe that the child will read from
192194
1 => array('file', $binfile . '.out', 'w'), // stdout is a file that the child will write to

0 commit comments

Comments
 (0)