Closed ani300 closed 12 years ago
Thanks for reporting.
Yes, I met the same problem in Ubuntu 11.04 just now. I will debug it in two days or more later.
I guess the problem may be inside the libsandbox. If so, it is not easy to handle. But I will try.
Hi,
Can you help me to test the latest code and report the result? It maybe fixed this bug. Thanks
I all works OK by now! I've made a few changes to the default permission on policy.c because if not the tests wouldn't run OK (I think it was the write permission or so). I've tested it with simple programs and all seem to be working just OK! Thank you very much.
Thank you for testing and report.
PS. I just fixed another important bug, don't forget to update.
when I compling the local sandbox environment in an CentOS 5.5 (x86) in a virtual machine, The make tries to run the runtest.sh, show 错误 2. Why could it happen? Detecting syscalls... INIT_SYSCALLS: 122, 45, 45, 243, 45, 45, ALLOWED_SYSCALLS: 197, 54, 192, 3, 45, 91, 125, 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 -D POLICY3 -I ./libsandbox/src -o sand sand.o policy.o ./libsandbox/libsandbox.a ./runtest.sh 1 stdin_test < /dev/null make: *\ [stdin] 错误 2
Could you follow the FAQ at https://github.com/hit-moodle/moodle-local_onlinejudge/wiki and post outputs here? Thanks
I followed the FAQ at https://github.com/hit-moodle/moodle-local_onlinejudge/wiki. Outputs:
[root@sei sand]# uname -a
Linux sei.edu.cn 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux
[root@sei sand]# cc -v
使用内建 specs。
目标:i386-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-cxaatexit --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=i386-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20080704 (Red Hat 4.1.2-50)
[root@sei sand]# make clean
make -C libsandbox clean
make[1]: Entering directory /var/www/html/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.17 make[1]: Leaving directory
/var/www/html/moodle/local/onlinejudge/judge/sandbox/sand/libsandbox'
rm -f .o *_test detector 223 policy.c
rm -f sand
[root@sei 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 `/var/www/html/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`/var/www/html/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, 45, 91, 125,
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 -D POLICY3 -I ./libsandbox/src -o sand sand.o policy.o ./libsandbox/libsandbox.a
./runtest.sh 1 stdintest < /dev/null
make: ** [stdin] 错误 2
Could you run strace ./stdin_test
and post the output?
OK, it output: [root@sei sand]# strace ./stdin_test execve("./stdin_test", ["./stdin_test"], [/* 38 vars */]) = 0 uname({sys="Linux", node="sei.ynu.edu.cn", ...}) = 0 brk(0) = 0x8c93000 brk(0x8c93cb0) = 0x8c93cb0 set_thread_area({entry_number:-1 -> 6, base_addr:0x8c93830, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 brk(0x8cb4cb0) = 0x8cb4cb0 brk(0x8cb5000) = 0x8cb5000 fstat64(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f79000 read(0, "\n", 4096) = 1 read(0, "\n", 4096) = 1 read(0, "\n", 4096) = 1 read(0, "\n", 4096) = 1 read(0, 0xb7f79000, 4096) = ? ERESTARTSYS (To be restarted) [root@sei sand]#
Did you break the program by ctrl+c? Use ctrl+D instead pls.
Yes, I do. Try ctrl+D, Outputs are: [root@sei sand]# strace ./stdin_test execve("./stdin_test", ["./stdin_test"], [/* 38 vars */]) = 0 uname({sys="Linux", node="sei.ynu.edu.cn", ...}) = 0 brk(0) = 0x80e6000 brk(0x80e6cb0) = 0x80e6cb0 set_thread_area({entry_number:-1 -> 6, base_addr:0x80e6830, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 brk(0x8107cb0) = 0x8107cb0 brk(0x8108000) = 0x8108000 fstat64(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f76000 read(0, "", 4096) = 0 exit_group(0) = ?
Then try this:
make policy.c
./detector -l memory=2000000000 223 < /dev/null
echo $?
[root@sei sand]# make policy.c
make -C libsandbox libsandbox.a
make[1]: Entering directory /var/www/html/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 r - src/platform.o r - src/sandbox.o r - src/symbols.o make[1]: Leaving directory
/var/www/html/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, 45, 91, 125,
[root@sei sand]# ./detector -l memory=2000000000 223 < /dev/null
122
45
45
243
45
45
223
197
54
192
3
197
192
192
45
192
192
91
91
125
192
You did not post the output of echo $?
which is important
[root@sei sand]# echo $? 6
Yep. I believe that if you run ./223 < /dev/null
, you will get SIGSEGV.
Does your system have some restriction about memory usage. 223.c tries to use 1GB memory. It is ok on my ubuntu, debian and centos 5.5. I don't know why it does not work on yours. You can edit 223.c and change the HEAP_ALLOC_SIZE to a smaller size, such as 128MB or so. Perhaps it works.
Yes, you are right. I changed the HEAP_ALLOC_SIZE to 128MB. it's OK. Thanks! ./runtest.sh 7 return1_test All testcases are OK
The menory for my CentOS 5.5 virtual machine is 512MB.
Just learned about sunner's fix. I have indeed released an updated version of libsandbox to tackle the very issue. To avoid further code branching, I would recommend an upgrade of the libsandbox code distributed with this project from 0.2.17 to 0.2.18. The latest version of libsandbox is available at https://sourceforge.net/projects/libsandbox/.
After compling the local sandbox environment in an Ubuntu 11.04 (x86) in a virtual machine, I find that when make tries to run the tests libsandbox just keeps throwing status 8 (Internal error). Why could it happen? If more information about the system is needed just ask for it. Thank you!