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

Java Jail not working with safeexec on CentOS #7

Closed
susobhang70 opened this Issue Nov 6, 2015 · 10 comments

Comments

Projects
None yet
2 participants
@susobhang70

susobhang70 commented Nov 6, 2015

Hi,
I am having an issue with safeexec and java_jail. I'm on CentOS release 5.8 (Final)

When I try this command from java_jail (i.e. without chroot):
/home/ssad1/safeexec/safeexec --share_newnet --nproc 50 --mem 30000000 --nfile 30 --env_vars CLASSPATH=./cp/:./cp/javax.json-1.0.jar:./java/lib/tools.jar --exec ./java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt

Output is:
Exception in thread "event-handler" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at traceprinter.JSONTracingThread.handleEvent(JSONTracingThread.java:221)
at traceprinter.JSONTracingThread.run(JSONTracingThread.java:136)
OK
elapsed time: 2 seconds
memory usage: 5092524 kbytes
cpu usage: 1.585 seconds

When I run this:
/home/ssad1/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 3000000 --nfile 30 --env_vars CLASSPATH=/cp/:/cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt

Output is:
Error occurred during initialization of VM
Could not allocate metaspace: 1073741824 bytes
Command exited with non-zero status (1)
elapsed time: 0 seconds
memory usage: 0 kbytes
cpu usage: 0.000 seconds

When I subsequently increase --mem, here is what i get:
1. 4000000
/home/ssad1/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 4000000 --nfile 30 --env_vars CLASSPATH=/cp/:./cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt

Error occurred during initialization of VM
Could not allocate metaspace: 1073741824 bytes
Command exited with non-zero status (1)
elapsed time: 0 seconds
memory usage: 0 kbytes
cpu usage: 0.004 seconds

2. 5000000

/home/ssad1/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 5000000 --nfile 30 --env_vars CLASSPATH=/cp/:./cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt
#

There is insufficient memory for the Java Runtime Environment to continue.

pthread_getattr_np

[thread 139926425515776 also had an error]

An error report file with more information is saved as:

//hs_err_pid10797.log

Command exited with non-zero status (1)
elapsed time: 1 seconds
memory usage: 4824000 kbytes
cpu usage: 1.353 seconds

3. 6000000
/home/ssad1/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 6000000 --nfile 30 --env_vars CLASSPATH=/cp/:./cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt
Exception in thread "event-handler" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at traceprinter.JSONTracingThread.handleEvent(JSONTracingThread.java:221)
at traceprinter.JSONTracingThread.run(JSONTracingThread.java:136)
OK
elapsed time: 2 seconds
memory usage: 5092532 kbytes
cpu usage: 1.482 seconds

Going above 6000000 produces the same result over and over again

@daveagp

This comment has been minimized.

Show comment
Hide comment
@daveagp

daveagp Nov 7, 2015

Owner

Can you try adding -Xmx1000m after /java/bin/java?

Do putting in the same numbers always cause the same errors even if you repeat them?

Owner

daveagp commented Nov 7, 2015

Can you try adding -Xmx1000m after /java/bin/java?

Do putting in the same numbers always cause the same errors even if you repeat them?

@susobhang70

This comment has been minimized.

Show comment
Hide comment
@susobhang70

susobhang70 Nov 7, 2015

Tried with -Xmx1000m

/home/ssad1/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 5000000 --nfile 30 --env_vars CLASSPATH=/cp/:./cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java -Xmx1000m traceprinter.InMemory < cp/traceprinter/test-input.txt

Exception in thread "event-handler" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at traceprinter.JSONTracingThread.handleEvent(JSONTracingThread.java:221)
at traceprinter.JSONTracingThread.run(JSONTracingThread.java:136)
OK
elapsed time: 2 seconds
memory usage: 4071456 kbytes
cpu usage: 1.577 seconds

As for trying again with the same numbers, I tried all of them again. Everyone produced the same error, except 5000000 printed the log file on the screen itself (said it can't write to log file so dumping to screen). The output is too big and I cannot attach it here it seems (write permission to repo error).

Another observation: every log file present in java_jail is empty.

susobhang70 commented Nov 7, 2015

Tried with -Xmx1000m

/home/ssad1/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 5000000 --nfile 30 --env_vars CLASSPATH=/cp/:./cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java -Xmx1000m traceprinter.InMemory < cp/traceprinter/test-input.txt

Exception in thread "event-handler" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at traceprinter.JSONTracingThread.handleEvent(JSONTracingThread.java:221)
at traceprinter.JSONTracingThread.run(JSONTracingThread.java:136)
OK
elapsed time: 2 seconds
memory usage: 4071456 kbytes
cpu usage: 1.577 seconds

As for trying again with the same numbers, I tried all of them again. Everyone produced the same error, except 5000000 printed the log file on the screen itself (said it can't write to log file so dumping to screen). The output is too big and I cannot attach it here it seems (write permission to repo error).

Another observation: every log file present in java_jail is empty.

@daveagp

This comment has been minimized.

Show comment
Hide comment
@daveagp

daveagp Nov 7, 2015

Owner

You can also try increasing the "Xmx512M" inside of InMemory.java. I know it's annoying to have three parameters to tweak, but the --mem one being gigantic (30 million k = 30 g) should make that one a non-issue.

Owner

daveagp commented Nov 7, 2015

You can also try increasing the "Xmx512M" inside of InMemory.java. I know it's annoying to have three parameters to tweak, but the --mem one being gigantic (30 million k = 30 g) should make that one a non-issue.

@susobhang70

This comment has been minimized.

Show comment
Hide comment
@susobhang70

susobhang70 Nov 7, 2015

I tweaked Xmx512M to Xmx1024M, Xmx2048M, and Xmx4096M. Same result. I had set --mem as 30000000. Here is what I got:

Exception in thread "event-handler" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at traceprinter.JSONTracingThread.handleEvent(JSONTracingThread.java:221)
at traceprinter.JSONTracingThread.run(JSONTracingThread.java:136)
OK
elapsed time: 1 seconds
memory usage: 5092532 kbytes
cpu usage: 1.523 seconds

susobhang70 commented Nov 7, 2015

I tweaked Xmx512M to Xmx1024M, Xmx2048M, and Xmx4096M. Same result. I had set --mem as 30000000. Here is what I got:

Exception in thread "event-handler" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at traceprinter.JSONTracingThread.handleEvent(JSONTracingThread.java:221)
at traceprinter.JSONTracingThread.run(JSONTracingThread.java:136)
OK
elapsed time: 1 seconds
memory usage: 5092532 kbytes
cpu usage: 1.523 seconds

@susobhang70

This comment has been minimized.

Show comment
Hide comment
@susobhang70

susobhang70 Nov 7, 2015

Update: I increased nproc to 100 and mem as 30000000. Got proper output. Even with Xmx512M. But error while running on front end.
screenshot from 2015-11-07 15 32 08

susobhang70 commented Nov 7, 2015

Update: I increased nproc to 100 and mem as 30000000. Got proper output. Even with Xmx512M. But error while running on front end.
screenshot from 2015-11-07 15 32 08

@daveagp

This comment has been minimized.

Show comment
Hide comment
@daveagp

daveagp Nov 7, 2015

Owner

Put all of the values you discovered worked into jv-config.json (safeexec_mem_k, Xmx)
Add
"safeexec_args" : {"nproc" : "100"}
to set the nproc.

Owner

daveagp commented Nov 7, 2015

Put all of the values you discovered worked into jv-config.json (safeexec_mem_k, Xmx)
Add
"safeexec_args" : {"nproc" : "100"}
to set the nproc.

@susobhang70

This comment has been minimized.

Show comment
Hide comment
@susobhang70

susobhang70 Nov 8, 2015

Thank you for everything. 👍

My team is also trying to integrate this with a offline visual debugger called Jeliot, and planning to launch it via JNLP from this site itself.

I'm making changes to the front end, adding save code functionality, and changing the look. I'm attaching a screenshot of the same. Hope you like it :)

screenshot from 2015-11-08 20 55 16

susobhang70 commented Nov 8, 2015

Thank you for everything. 👍

My team is also trying to integrate this with a offline visual debugger called Jeliot, and planning to launch it via JNLP from this site itself.

I'm making changes to the front end, adding save code functionality, and changing the look. I'm attaching a screenshot of the same. Hope you like it :)

screenshot from 2015-11-08 20 55 16

@daveagp

This comment has been minimized.

Show comment
Hide comment
@daveagp

daveagp Nov 8, 2015

Owner

Looks great! If you get it working with Jeliot, let me know, that would be very interesting.

Owner

daveagp commented Nov 8, 2015

Looks great! If you get it working with Jeliot, let me know, that would be very interesting.

@daveagp daveagp closed this Nov 8, 2015

@susobhang70

This comment has been minimized.

Show comment
Hide comment
@susobhang70

susobhang70 Nov 9, 2015

This is how it looks now. I've added a Save Code button and a Start with Jeliot button, which actually launches jeliot with this code. The written code is saved in the server and a corresponding JNLP file is generated to launch Jeliot on the client side (user still has to launch the JNLP file). I've been working on it's Moodle plugin for a month now, and managed to fix the bugs for the newer Moodle versions, and applied the same technique to achieve this mechanism.

My initial plans were to also integrate your debugger to Moodle, but unfortunately neither me nor my team have much time to achieve that functionality.

screenshot from 2015-11-10 02 02 07

susobhang70 commented Nov 9, 2015

This is how it looks now. I've added a Save Code button and a Start with Jeliot button, which actually launches jeliot with this code. The written code is saved in the server and a corresponding JNLP file is generated to launch Jeliot on the client side (user still has to launch the JNLP file). I've been working on it's Moodle plugin for a month now, and managed to fix the bugs for the newer Moodle versions, and applied the same technique to achieve this mechanism.

My initial plans were to also integrate your debugger to Moodle, but unfortunately neither me nor my team have much time to achieve that functionality.

screenshot from 2015-11-10 02 02 07

@daveagp

This comment has been minimized.

Show comment
Hide comment
@daveagp

daveagp Nov 10, 2015

Owner

Looks nice, keep up the good work!

Owner

daveagp commented Nov 10, 2015

Looks nice, keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment