This happens on Rust 1.59 and Rust 1.60, not sure if the toolchain is related. I use Tokio 1.17.
I have a very weird case in which I get an error but I have no clue why. A result is returned and then it crashes, I am unable to locate why. It worked before, but I am not sure why it suddenly doesn't work anymore (it is a test and I didn't run it in a while).
I can not give you a minimal reproduction project, because it works in projects where I try to reproduce it. I can however give you information about my own project where it fails.
This is the code snippet where I return the result of a method call
When using breakpoints, I can verify that the calling method receives the return value
(see comment, I can only post 1 image...)
However, when I want to continue, it crashes:
(see comment, I can only post 1 image...)
This is in the logs when I use breakpoints:
Exception: EXC_BAD_ACCESS (code=2, address=0x70000bff9278)
When I don't do breakpoints (just run the application without debug mode), this error is logged:
Apr 13 09:39:33.793 DEBUG message_processor::messages::request_processor: 222222222
thread 'tokio-runtime-worker' has overflowed its stack
fatal runtime error: stack overflow
I don't know why it overflowes its stack. I tried increasing the stack size by a lot, but that didn't work:
thread_stack_size(10 * 1024 * 1024)
It is also strange: a result is returned from a method and then this error is logged.
The logging (the 2's) is showing us that the method call was successfully and it returns the result. The 3's are not logged, indicating something is going wrong when trying to use the returned value. In the screenshots I provided, you can read the print statements.
I am not sure how to debug this further. Any suggestions?