-
Notifications
You must be signed in to change notification settings - Fork 121
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
Interrupt a script/eval #7
Comments
I've been asked this before. The problem is that there is only one reliable way to execute untrusted code, and that is to run it inside it's own process. A timeout will not save you; for example, the script could allocate arbitrary amounts of memory, or it could cause a stack overflow exception by recursively calling a function a million times. (The stack overflow exception, in particular, will inevitably result in your app crashing). I do actually need to do something similar to run the unit test suite reliably. If I can make it generic enough, I'll consider pulling this code out into a couple of helper classes. |
I'm wondering: what's the problem with using I wouldn't shy back from using |
I want to let js call stuff in my .net code. The logfile stuff i could find other non-ideal solutions for. But releasing locks? Not that I'm aware of. |
Thread.Abort() is fine if you just want to implement a time-out. It's not fine if you are trying to safely execute untrusted code. My belief is that people who ask for the former generally actually need the latter. |
Locks should not be a problem if you implement them correctly. About untrusted code. Generally C# is supposed to be written exception safe. This means that you're supposed to always clean up in a I know that |
That is very interesting. Thank you for that writeup. So thanks again for clearing that up. I will test Thread.Abort in a few usage scenarios then and see if it really works well for my case. |
Hi, im using jurassic to let users run scripts, but i need to add a timeout for them so they can't mess up my server with "while(true) ;"
Is there any callback or something to do that?
Or do I have to go the ugly route of Thread.Abort() ?? That'd be pretty sad :(
The text was updated successfully, but these errors were encountered: