Automatically exit app on StackOverflowException

Hi.

Xojo 2024R2.1, Linux 64-bit build.

The app stops with next error:
An exception of class StackOverflowException was not handled. The application must shut down.

Is there a way to force the app automatically exit/shutdown in this case? So the service can be restarted automatically by Lifeboat setup?

Looks like it stays in memory but does not respond on requests.

Return False on App.UnhandledException didn’t help.

PS: I know that the correct way is just to solve the infinite loop. But the app is too complex and many devs are working on it. So it happens from time to time.

Thanks

Perhaps put Quit() in the App.UnhandledException handler (haven’t tried this).

Copied / Pasted on the documentation and:

https://documentation.xojo.com/api/exceptions/stackoverflowexception.html#stackoverflowexception

Code sample was shared…

It doesn’t look like code ever executed in App.UnhandledException on StackOverflowException

It is not a way if the APP has dozens of different APIs, third parties etc. It is not possible to cover with this code ALL places.

But the app should exit on this error, and not stay in the memory as dead

If the app becomes really out of control that way, you could send a kill signal to the process. Not an elegant solution, nor something I’d normally advise, but perhaps it’s an edge case where it would make sense (temporarily until you find the culprit).

This seems like someone on your team inserted an exception statement somewhere along the stack to catch all things. The purpose of that is to prevent App.UnhandledException… which I don’t recommend ever.

There is a long standing bug where the return value of App.UnhandledException is never taken into account. Calling Quit from the event doesn’t even work. You have to relay the Quit through a Timer.

Edit: Reordered some words for clarity

3 Likes

Thank you! Looks like it (quit by timer) is the way.