Failed to register: Timeout was reached, deadlock inside geary_logging_default_log_writer()
Since 3.34, Geary occasionally gets into a state where it is impossible to launch. After waiting a while we see this familiar GApplication error message:
$ geary
Failed to register: Timeout was reached
It means a previous instance is still running in the background and is not responding to the activate signal. Basically the previous instance of Geary failed to exit like it should have.
I got a backtrace to the hung process and it looks... interesting. Lots of recursion here inside geary_logging_record_finalize(), though note each frame is a different instance, so one frame is calling the next, not infinite recursion. Then we have it blocked on a mutex lock in Geary's log writer. The backtrace is very long because I decided it might be important to have all threads for this due to the mutex, but actually I think only the main thread is important. Without looking at the code, I think the problem is the lock, not the recursion. I let geary continue execution and took another backtrace a bit later, and it looks exactly the same, so it's surely a deadlock trying to acquire that lock, which is odd because none of the other stack frames are inside geary_logging_default_log_writer().