I have an architecture with 2 threads, the main thread and a worker thread that has a larger-than-normal stack.
It has happened once or twice that the worker thread has overflowed its stack, at which point the entire program aborts.
This abortion behavior is very undesirable. What I want instead is to get some kind of error signal which I can use in the main thread to restart the thread and its contents.
I thought I could accomplish that with std::panic::catch_unwind()
, but it turns out that that is useless when trying to prevent aborts.
Does Rust have a reliable way to turn aborts into an error signal? At this point I donât even care about things like an error cause; The combination of not bluntly aborting on the one hand, plus being able to restart the busted thread on the other, would allow me to at least implement a reliable recovery strategy.
BTW: As for why I have 1 single worker thread, thatâs because itâs not possible to alter the stack size of the main thread in Rust, whereas it is possible to do using user-managed threads. The single-thread solution would have had my preference; The extra thread is a necessary but rather hard-handed and blunt workaround.