google-deepmind / code_contests

Apache License 2.0
2.04k stars 200 forks source link

solve_example SolveGregorAndCryptography compilation fails for all examples #12

Closed KareemAlaa2001 closed 2 years ago

KareemAlaa2001 commented 2 years ago

When attempting to run the solve_example script using the second given command with the python2 and 3 paths specified on a Ubuntu 20 system, the build completes successfully however the compilation fails for all three given examples for the SolveGregorAndCryptography function. The full stack trace is shown below:

$ bazel run -c opt execution:solve_example -- --valid_path=/mnt/c/Users/DELL/Documents/UoE/MLP/cw4/CodeContest/dm-code_contests/code_contests_valid.riegeli --python3_path=/home/allen/anaconda3/bin/python --python3_library_paths=/home/allen/anaconda3/lib/python --python2_path=/usr/bin/python2 --python2_library_paths=/usr/lib/python2
Starting local Bazel server and connecting to it...
INFO: Analyzed target //execution:solve_example (88 packages loaded, 2108 targets configured).
INFO: Found 1 target...
INFO: From Compiling sandboxed_api/tools/filewrapper/filewrapper.cc [for host]:
In file included from external/com_google_sandboxed_api/sandboxed_api/tools/filewrapper/filewrapper.cc:29:
external/com_google_sandboxed_api/sandboxed_api/util/fileops.h:24:15: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace sapi::file_util::fileops {
              ^~~~~~~~~~~~~~~~~~~~
               { namespace file_util { namespace fileops
In file included from external/com_google_sandboxed_api/sandboxed_api/tools/filewrapper/filewrapper.cc:30:
external/com_google_sandboxed_api/sandboxed_api/util/raw_logging.h:134:15: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace sapi::raw_logging_internal {
              ^~~~~~~~~~~~~~~~~~~~~~
               { namespace raw_logging_internal
2 warnings generated.
INFO: From Compiling sandboxed_api/util/raw_logging.cc [for host]:
In file included from external/com_google_sandboxed_api/sandboxed_api/util/raw_logging.cc:15:
external/com_google_sandboxed_api/sandboxed_api/util/raw_logging.h:134:15: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace sapi::raw_logging_internal {
              ^~~~~~~~~~~~~~~~~~~~~~
               { namespace raw_logging_internal
external/com_google_sandboxed_api/sandboxed_api/util/raw_logging.cc:107:15: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace sapi::raw_logging_internal {
              ^~~~~~~~~~~~~~~~~~~~~~
               { namespace raw_logging_internal
2 warnings generated.
INFO: From Compiling sandboxed_api/util/fileops.cc [for host]:
In file included from external/com_google_sandboxed_api/sandboxed_api/util/fileops.cc:15:
external/com_google_sandboxed_api/sandboxed_api/util/fileops.h:24:15: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace sapi::file_util::fileops {
              ^~~~~~~~~~~~~~~~~~~~
               { namespace file_util { namespace fileops
external/com_google_sandboxed_api/sandboxed_api/util/fileops.cc:29:15: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace sapi::file_util::fileops {
              ^~~~~~~~~~~~~~~~~~~~
               { namespace file_util { namespace fileops
2 warnings generated.
Target //execution:solve_example up-to-date:
  bazel-bin/execution/solve_example
INFO: Elapsed time: 90.415s, Critical Path: 28.07s
INFO: 685 processes: 5 internal, 680 linux-sandbox.
INFO: Build completed successfully, 685 total actions
INFO: Running command line: bazel-bin/execution/solve_example '--valid_path=/mnt/c/Users/DELL/Documents/UoE/MLP/cw4/CodeINFO: Build completed successfully, 685 total actions
We will try to solve "Gregor and Cryptography":
https://codeforces.com/problemset/problem/1549/A

We will run:
  1. A program that does not compile.
  2. A program that runs successfully, but gives the wrong answer sometimes.
  3. A correct solution.

--------------------------------------------------------------------------------
An invalid program is reported as not compiling:

[global_forkclient.cc : 122] RAW: Starting global forkserver
WARNING: Logging before InitGoogleLogging() is written to STDERR
E20220322 11:50:05.226009  2539 monitor.cc:842] SANDBOX VIOLATION : PID: 2544, PROG: 'python3.9' : [X86-64] arch_prctl [158](0x3001 [12289], 0x7ffe3e622a60) IP: 0x7f79db5c0be5, STACK: 0x7ffe3e622a10
I20220322 11:50:05.226202  2539 monitor.cc:386] Stack traces have been disabled
Compilation failed

--------------------------------------------------------------------------------
The bad solution passes a few tests but then fails.
Because we set stop_on_first_failure to True, we stop once we see a failure.
We are running on 4 threads, so it's possible that more than one failure occurs
before all threads stop.

E20220322 11:50:05.231288  2545 monitor.cc:842] SANDBOX VIOLATION : PID: 2548, PROG: 'python3.9' : [X86-64] arch_prctl [158](0x3001 [12289], 0x7ffefd9ac980) IP: 0x7f6e16896be5, STACK: 0x7ffefd9ac930
I20220322 11:50:05.231374  2545 monitor.cc:386] Stack traces have been disabled
Compilation failed

--------------------------------------------------------------------------------
The good solution passes all tests.

E20220322 11:50:05.235946  2549 monitor.cc:842] SANDBOX VIOLATION : PID: 2552, PROG: 'python3.9' : [X86-64] arch_prctl [158](0x3001 [12289], 0x7ffe11fd4d30) IP: 0x7f0925a06be5, STACK: 0x7ffe11fd4ce0
I20220322 11:50:05.236099  2549 monitor.cc:386] Stack traces have been disabled
Compilation failed

clang --version:

clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
davidhchoi commented 2 years ago

It looks like it's making a syscall that the sandbox doesn't allow. Does it work if you explicitly add that syscall to what's allowed by the sandbox? Adding builder.AllowSyscall(__NR_arch_prctl); to here and here.

KareemAlaa2001 commented 2 years ago

This seems to make that specific error go away, however we are now running into a separate issue where the compilation fails for all three examples without any error message:

We will try to solve "Gregor and Cryptography":
https://codeforces.com/problemset/problem/1549/A

We will run:
  1. A program that does not compile.
  2. A program that runs successfully, but gives the wrong answer sometimes.
  3. A correct solution.

--------------------------------------------------------------------------------
An invalid program is reported as not compiling:

[global_forkclient.cc : 122] RAW: Starting global forkserver
Compilation failed

--------------------------------------------------------------------------------
The bad solution passes a few tests but then fails.
Because we set stop_on_first_failure to True, we stop once we see a failure.
We are running on 4 threads, so it's possible that more than one failure occurs
before all threads stop.

Compilation failed

--------------------------------------------------------------------------------
The good solution passes all tests.

Compilation failed

The syscall was added to both specified locations with everything else being kept as is

davidhchoi commented 2 years ago

Ok, can you print out more information to where it prints compilation failed here? In particular, multi_result.compilation_result.stdoutand multi_result.compilation_result.stderr.

KareemAlaa2001 commented 2 years ago

So having done that, we realised that the passed in paths for python3 to the run command were not exactly correct 😅 updating that fixed our issue. Thanks!