Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sandbox错误:255 #38

Closed
zgjava opened this issue Mar 21, 2012 · 17 comments
Closed

sandbox错误:255 #38

zgjava opened this issue Mar 21, 2012 · 17 comments

Comments

@zgjava
Copy link

zgjava commented Mar 21, 2012

程序提交后显示:内部错误!sandbox错误255

uname -a

Linux localhost 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

cc -v

使用内建 specs。
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-50)

cd /usr/local/apache/htdocs/moodle

[root@localhost moodle]# cd local/onlinejudge
[root@localhost onlinejudge]# cd judge
[root@localhost judge]# cd sandbox
[root@localhost sandbox]# cd sand
[root@localhost sand]# uname -a
Linux localhost 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost sand]# cc -v
使用内建 specs。
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-50)
[root@localhost sand]# make clean
make -C libsandbox clean
make[1]: Entering directory /usr/local/apache/htdocs/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox' rm -rf doc rm -f src/platform.o src/sandbox.o src/symbols.o libsandbox.a libsandbox.so \ libsandbox.so.0.2.18 make[1]: Leaving directory/usr/local/apache/htdocs/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox'
rm -f *.o *_test detector 223 policy.c
rm -f sand
[root@localhost sand]# make
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o stdin_test testcase/stdin.c
make -C libsandbox libsandbox.a
make[1]: Entering directory /usr/local/apache/htdocs/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox' cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -shared -fPIC -pthread -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITH_NATIVE_MONITOR -D WITHOUT_TSC_COUNTER -I src -c -o src/platform.o src/platform.c cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -shared -fPIC -pthread -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITH_NATIVE_MONITOR -D WITHOUT_TSC_COUNTER -I src -c -o src/sandbox.o src/sandbox.c src/sandbox.c: In function ‘__sandbox_tracer’: src/sandbox.c:1030: 警告:标号 ‘next’ 定义后未使用 cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -shared -fPIC -pthread -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITH_NATIVE_MONITOR -D WITHOUT_TSC_COUNTER -I src -c -o src/symbols.o src/symbols.c ar rcvs libsandbox.a src/platform.o src/sandbox.o src/symbols.o a - src/platform.o a - src/sandbox.o a - src/symbols.o make[1]: Leaving directory/usr/local/apache/htdocs/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox'
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -c policy_print.c
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -c sand.c
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -o detector sand.o policy_print.o ./libsandbox/libsandbox.a
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o 223 223.c
./detect.sh
Detecting syscalls...
INIT_SYSCALLS: 122, 45, 45, 243, 45, 45,
ALLOWED_SYSCALLS: 197, 54, 192, 3, 91, 4, 252,
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -c policy.c
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACER -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -o sand sand.o policy.o ./libsandbox/libsandbox.a
./runtest.sh 1 stdin_test < /dev/null
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o stdout_test testcase/stdout.c
./runtest.sh 1 stdout_test > /dev/null
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o fork_test testcase/fork.c
./runtest.sh 2 fork_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o open_test testcase/open.c
./runtest.sh 2 open_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o memlimit_test testcase/memlimit.c
./runtest.sh 3 -l memory=1048576 memlimit_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o cpulimit_test testcase/cpulimit.c
./runtest.sh 5 -l cpu=1000 cpulimit_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o sigsegv_test testcase/sigsegv.c
./runtest.sh 6 sigsegv_test > /dev/null
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o return1_test testcase/return1.c
./runtest.sh 7 return1_test
All testcases are OK
make -C libsandbox clean
make[1]: Entering directory /usr/local/apache/htdocs/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox' rm -rf doc rm -f src/platform.o src/sandbox.o src/symbols.o libsandbox.a libsandbox.so \ libsandbox.so.0.2.18 make[1]: Leaving directory/usr/local/apache/htdocs/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox'
rm -f *.o *_test detector 223 policy.c

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

[root@localhost bin]# g++ -v
使用内建 specs。
目标:x86_64-redhat-linux6E
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --disable-gnu-unique-object --enable-languages=c,c++,fortran --disable-libgcj --with-mpfr=/builddir/build/BUILD/gcc-4.4.4-20100726/obj-x86_64-redhat-linux6E/mpfr-install/ --with-ppl=/builddir/build/BUILD/gcc-4.4.4-20100726/obj-x86_64-redhat-linux6E/ppl-install --with-cloog=/builddir/build/BUILD/gcc-4.4.4-20100726/obj-x86_64-redhat-linux6E/cloog-install --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux6E
线程模型:posix
gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)

[root@localhost bin]# gcc -v
使用内建 specs。
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-50)

@sunner
Copy link
Member

sunner commented Mar 22, 2012

Do all kinds of program get the same result?

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

yes,all kinds of program

@sunner
Copy link
Member

sunner commented Mar 22, 2012

But OJ should never print the string "内部错误!sandbox错误255". What exactly it looks like?

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

状态: 内部错误
标准输出* 不可用
标准错误输出* 不可用
编译器输出 不可用
敏感信息* 不可用
信息 沙箱错误:255
CPU使用时间 不可用
内存使用量 不可用

  • 只教师可见

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

问题起初是因为升级gcc从4.1.2到gcc4.4.7,发现不能用。现在还原为gcc4.1.2,就出现这个情况

@sunner
Copy link
Member

sunner commented Mar 22, 2012

Try rerun judged.php . If still the problem, post output of cc -v and gcc -v

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

[root@localhost cli]# sudo -u apache php judged.php
Judge daemon successfully created. PID = 12681
[root@localhost cli]# cc -v
使用内建 specs。
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-52)
[root@localhost cli]# gcc -v
使用内建 specs。
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-52)

@sunner
Copy link
Member

sunner commented Mar 22, 2012

Rerun means you should kill all old judged first

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

yes,but yet error

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

[root@localhost judge]# cd sandbox/sand && make
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o stdin_test testcase/stdin.c
make -C libsandbox libsandbox.a
make[1]: Entering directory /usr/local/apache/htdocs/moodle/local/onlinejudge/j udge/sandbox/sand/libsandbox' cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -shared -fPIC -pthread -D SANDBOX -D NDE BUG -D WITH_NATIVE_TRACER -D WITH_NATIVE_MONITOR -D WITHOUT_TSC_COUNTER -I src - c -o src/platform.o src/platform.c cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -shared -fPIC -pthread -D SANDBOX -D NDE BUG -D WITH_NATIVE_TRACER -D WITH_NATIVE_MONITOR -D WITHOUT_TSC_COUNTER -I src - c -o src/sandbox.o src/sandbox.c src/sandbox.c: In function ‘__sandbox_tracer’: src/sandbox.c:1030: 警告:标号 ‘next’ 定义后未使用 cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -shared -fPIC -pthread -D SANDBOX -D NDE BUG -D WITH_NATIVE_TRACER -D WITH_NATIVE_MONITOR -D WITHOUT_TSC_COUNTER -I src - c -o src/symbols.o src/symbols.c ar rcvs libsandbox.a src/platform.o src/sandbox.o src/symbols.o a - src/platform.o a - src/sandbox.o a - src/symbols.o make[1]: Leaving directory/usr/local/apache/htdocs/moodle/local/onlinejudge/ju dge/sandbox/sand/libsandbox'
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACE R -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -c policy_print.c
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACE R -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -c sand.c
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACE R -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -o detector sand.o policy_print.o ./libsandbox/libsandbox.a
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o 223 223.c
./detect.sh
Detecting syscalls...
INIT_SYSCALLS: 122, 45, 45, 243, 45, 45,
ALLOWED_SYSCALLS: 197, 54, 192, 3, 91, 4, 252,
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACE R -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -c policy.c
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 -D SANDBOX -D NDEBUG -D WITH_NATIVE_TRACE R -D WITHOUT_TSC_COUNTER -I ./libsandbox/src -o sand sand.o policy.o ./libsandb ox/libsandbox.a
./runtest.sh 1 stdin_test < /dev/null
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o stdout_test testcase/stdout.c
./runtest.sh 1 stdout_test > /dev/null
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o fork_test testcase/fork.c
./runtest.sh 2 fork_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o open_test testcase/open.c
./runtest.sh 2 open_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o memlimit_test testcase/memlim it.c
./runtest.sh 3 -l memory=1048576 memlimit_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o cpulimit_test testcase/cpulim it.c
./runtest.sh 5 -l cpu=1000 cpulimit_test
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o sigsegv_test testcase/sigsegv .c
./runtest.sh 6 sigsegv_test > /dev/null
cc -m32 -Wall -ansi -std=gnu99 -g0 -O3 --static -o return1_test testcase/return1 .c
./runtest.sh 7 return1_test
All testcases are OK
make -C libsandbox clean
make[1]: Entering directory /usr/local/apache/htdocs/moodle/local/onlinejudge/j udge/sandbox/sand/libsandbox' rm -rf doc rm -f src/platform.o src/sandbox.o src/symbols.o libsandbox.a libsandbox.so \ libsandbox.so.0.2.18 make[1]: Leaving directory/usr/local/apache/htdocs/moodle/local/onlinejudge/ju dge/sandbox/sand/libsandbox'
rm -f *.o *_test detector 223 policy.c

@zgjava
Copy link
Author

zgjava commented Mar 22, 2012

[root@localhost cli]# ps -FC php
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
apache 3322 1 0 53854 54564 0 18:23 ? 00:00:08 php judged.php
apache 12783 1 0 52975 52348 0 21:18 ? 00:00:00 php judged.php
apache 12793 1 0 52085 47188 1 21:18 ? 00:00:00 php judged.php
[root@localhost cli]# kill 3322
[root@localhost cli]# ps -FC php
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
apache 12783 1 0 52975 52348 1 21:18 ? 00:00:00 php judged.php
apache 12793 1 0 52085 47188 0 21:18 ? 00:00:00 php judged.php
[root@localhost cli]# kill 12783
[root@localhost cli]# ps -FC php
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
apache 12793 1 0 52085 47188 0 21:18 ? 00:00:00 php judged.php
[root@localhost cli]# kill 12793
[root@localhost cli]# ps -FC php
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
[root@localhost cli]# sudo -u apache php judged.php
Judge daemon successfully created. PID = 12985
[root@localhost cli]# Judged inner level exception handler: 沙箱错误:255 Debug:

  • line 146 of /local/onlinejudge/judge/sandbox/lib.php: onlinejudge_exception th rown
  • line 95 of /local/onlinejudge/judge/sandbox/lib.php: call to judge_sandbox->ru n_in_sandbox()
  • line 358 of /local/onlinejudge/judgelib.php: call to judge_sandbox->judge()
  • line 171 of /local/onlinejudge/cli/judged.php: call to onlinejudge_judge()
  • line 120 of /local/onlinejudge/cli/judged.php: call to judge_all_unjudged()

Judged inner level exception handler: 沙箱错误:255 Debug:

  • line 146 of /local/onlinejudge/judge/sandbox/lib.php: onlinejudge_exception th rown
  • line 95 of /local/onlinejudge/judge/sandbox/lib.php: call to judge_sandbox->ru n_in_sandbox()
  • line 358 of /local/onlinejudge/judgelib.php: call to judge_sandbox->judge()
  • line 171 of /local/onlinejudge/cli/judged.php: call to onlinejudge_judge()
  • line 120 of /local/onlinejudge/cli/judged.php: call to judge_all_unjudged()

@sunner
Copy link
Member

sunner commented Mar 23, 2012

I don't know why. Perhaps some libs are broken during changing version of gcc.

Usually, getting All testcases are ok during make means no 255 error should throw.

@zgjava
Copy link
Author

zgjava commented Mar 27, 2012

升级后,能在shell中运行gcc编译,运行C程序,证明gcc 升级成功的啊

@sunner
Copy link
Member

sunner commented Mar 27, 2012

这样测试一下吧。弄一个简单的但是255的程序,比如hello.c,然后到命令行这样编译:

gcc -m32 -D_MOODLE_ONLINE_JUDGE_ -Wall -Werror -static -o hello hello.c -lm

然后到sand目录下,运行

./sand /path/to/hello
echo $?

假如最后的输出是255或-1,那么把你的sand和hello都发给我。否则,暂时还想不出什么办法……

@zgjava
Copy link
Author

zgjava commented Mar 28, 2012

我终于找到原因所在,前段时间为了安全起见,我设置了php.ini的disable_functions=phpinfo,passthru,exec,system,chroot,
scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,今天忽然想起,删掉disable_functions=后的设置即可!kill judge,再重启judge,一切OK!,太高兴了!

@sunner
Copy link
Member

sunner commented Mar 28, 2012

原来如此。
这里有些moodle自身也要用到的。

@sunner sunner closed this as completed Mar 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants