DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
737 stars 258 forks source link

Build script for executables should use chroot consistently with running them #2162

Open eldering opened 1 year ago

eldering commented 1 year ago

Description of the problem

Currently, executables are built using https://github.com/DOMjudge/domjudge/blob/main/judge/build_executable.sh. This runs inside the chroot, but the executable that gets built is run outside the chroot. This leads to incompatibility problems, see for example below with the glibc version, and causes internal errors.

Your environment

DOMjudge version 8.0 on CentOS 8 with chroot Debian Bookworm.

Steps to reproduce

Install the system, try to judge something.

Actual behaviour

Then get this internal error:

[Sep 27 07:27:31.221] judgedaemon[1421]: Building executable in /home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/run/3/8f6a40aab30f3a816e80bb1b76fc0d6c, under 'build/'
[Sep 27 07:27:31.439] judgedaemon[1421]:   💾 Fetching new executable 'compare/1' with hash '80822e09ea714b3238620203f466caff'.
[Sep 27 07:27:31.439] judgedaemon[1421]: API request GET judgehosts/get_files/compare/1
[Sep 27 07:27:31.600] judgedaemon[1421]: Building executable in /home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/compare/1/80822e09ea714b3238620203f466caff, under 'build/'
[Sep 27 09:27:32.197] testcase_run.sh[7439]: starting '/home/domjudge/domjudge/lib/judge/testcase_run.sh', PID = 7439
[Sep 27 09:27:32.200] testcase_run.sh[7439]: arguments: '/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/testcase/2055/7f930ff4f8b7fd3735aed2a13bce3380_652820dfe1f4660f8ad233ba09ad6eb3.in' '/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/testcase/2055/7f930ff4f8b7fd3735aed2a13bce3380_652820dfe1f4660f8ad233ba09ad6eb3.out' '1:6' '/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/1833/3764/testcase02055'
[Sep 27 09:27:32.202] testcase_run.sh[7439]: optionals: '/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/run/3/8f6a40aab30f3a816e80bb1b76fc0d6c/build/run' '/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/compare/1/80822e09ea714b3238620203f466caff/build/run' ''
[Sep 27 09:27:32.209] testcase_run.sh[7439]: setting up testing (chroot) environment
[Sep 27 09:27:32.216] testcase_run.sh[7439]: running program
[Sep 27 09:27:32.220] testcase_run.sh[7439]: runcheck: /home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/run/3/8f6a40aab30f3a816e80bb1b76fc0d6c/build/run testdata.in program.out sudo -n /home/domjudge/domjudge/bin/runguard -P 28 -r /home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/1833/3764/testcase02055/.. --nproc=64 --no-core --streamsize=8192 --user=domjudge-run-28 --group=domjudge-run --walltime=1:6 --cputime=1:6 --memsize=2097152 --filesize=8192 --stderr=program.err --outmeta=program.meta -- /testcase02055/execdir/program
[Sep 27 09:27:32.323] testcase_run.sh[7439]: comparing output
[Sep 27 09:27:32.327] testcase_run.sh[7439]: starting compare script '/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/compare/1/80822e09ea714b3238620203f466caff/build/run'
[Sep 27 09:27:32.330] testcase_run.sh[7439]: runcheck: sudo -n /home/domjudge/domjudge/bin/runguard -P 28 -u domjudge-run-28 -g domjudge-run -m 2097152 -t 30 -c -f 2621440 -s 2621440 -M compare.meta -- /home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/compare/1/80822e09ea714b3238620203f466caff/build/run testdata.in testdata.out feedback/
[Sep 27 09:27:32.393] testcase_run.sh[7439]: checking compare script exit-status: 1
[Sep 27 09:27:32.398] testcase_run.sh[7439]: Comparing failed with exitcode 1, compare script output:

---------- output validator stdout/stderr messages ----------
/home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/compare/1/80822e09ea714b3238620203f466caff/build/run: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /home/domjudge/domjudge/output/judgings/domjudge-201-28/endpoint-default/executable/compare/1/80822e09ea714b3238620203f466caff/build/run)
[Sep 27 09:27:32.406] testcase_run.sh[7439]: exiting with status '120'
[Sep 27 07:27:32.408] judgedaemon[1421]: comparing failed for compare script '1'

Remarks

So either the build script should not use the chroot or all the scripts that were built with it should be run inside this same chroot. A quick hack would be to explicitly compile any build scripts statically, either by specifying that at https://github.com/DOMjudge/domjudge/blob/main/judge/judgedaemon.main.php#L410-L413 or add a build script to the executable.

meisterT commented 1 year ago

This is basically about running compare scripts in the chroot, right? Everything else including compilation should be already in the chroot if I am not mistaken.