hugox14's blog

By hugox14, history, 2 months ago, In English,

Hi, I'm currently working on a project using PHP to develop a judge where my colleagues can send solutions to exercises that are typically from a basic programming course. All solutions must be written in python.

The code is executed in exec() and then the user's output is stored in a .txt file. Later the system reads that file and compares it with a .txt file that has the correct outputs.

The problem is that I can not know when TLE occurs. When a user sends a python file with an infinite buble for example, the web page hangs.

If you have some tip or similar experience I would appreciate it very much.

 
 
 
 
  • Vote: I like it  
  • +5
  • Vote: I do not like it  

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I've been searching for things about OJs for days and it's not only about time...

You should search more about many things like..

  • resource limit
  • disabling network
  • disabling sys calls
  • load balancing
  • disabling threading...
  • etc...
»
2 months ago, # |
  Vote: I like it -11 Vote: I do not like it

You can take a good method for every user that when a user send his/her code then it make a txt file and your compiler just check this and clean that code and then other do. and in this method you have to do write queue function (you can use ajax for do this )if you don't do that then you fetch many problems when the user database are huge.Or you can use one user one code compiler main file then your judge can handle huge user activity. Thank You.

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I found open source OJ

Link : https://github.com/shawon100/RUET-OJ

Link of Website : The online Judge

»
2 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Hi hugox14!

As EbraM96 said, if you are planning to create a robust OJ you should take into account security. Basically you should run the submissions on a sandbox environment to avoid problems.

Anyway, an easy way to limit execution time is with the "timeout" command.

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Wow the timeout command has helped me. I am using it in the following way:

    exec("timeout 1 python example.py < in.txt > out.txt")
    

    and now the process stops, although not after a second, I think that around 5 seconds. I will investigate that. Many thanks!