I have a thread in my application that is running code that can potentially cause call stack corruption ( my application is a testing tool for dlls ).
Assuming that I have a method of detecting if the child thread is misbehaving, how would I terminate it? From what I read, calling Thread.Abort() on the misbehaving thread would be equivalent to raising an exception inside it.I fear that that not be a good idea, provided the call stack of the thread might be corrupted.Any suggestions?
A stack overflow is a fatal error and can't be recovered from.
Remarks. StackOverflowException is thrown for execution stack overflow errors, typically in case of a very deep or unbounded recursion. So make sure your code doesn't have an infinite loop or infinite recursion.
A stack overflow is a type of buffer overflow error that occurs when a computer program tries to use more memory space in the call stack than has been allocated to that stack.
If you are running untrusted code that could corrupt your process run that code in a separate process and communicate with it using interprocess communication. If you want to terminate the untrusted code early, you can just kill the process.
If code is misbehaving, it can do anything, and it can affect anything in the entire process, on any thread.
The most reliable solution is to run the untrusted code in a separate process, then terminate the process if it misbehaves.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With