c# - Prevent Exception from crashing process
assume have application, user can provide script written in javascript perform task in it. done using jint. however, badly written script can cause stack overflow exception in jintengine.run()
, therefore crashing whole application. rather inform user error in script.
i tried run jint on application domain, did not help, cause afaik default action on soe exiting process. changed other way using clr hosting?
i know can run separate process , that's fallback, nevertheless not that.
as suspected, it's not possible catch stackoverflowexception generated runtime unless you're hosting clr [1]. microsoft documentation suggests, best bet try , detect stack overflow before happens.
in case of using jint, means finding way hook execution engine , attach own code arbitrary method calls. fortunately, brief overview of documentation reveals have debugging mode that! [2]
no doubt running in debugging mode means slowing down script execution; it's decide if benefit of detecting overflows worth penalty--and suggest measuring penalty ensure it's going problem. 1 possible mitigation allow user choose when debugging mode active.
-mark
[1] http://msdn.microsoft.com/en-us/library/system.stackoverflowexception.aspx (see remarks)
[2] http://jint.codeplex.com/wikipage?title=debugging&referringtitle=documentation
Comments
Post a Comment