Flush logs when crashing.#21517
Conversation
PunkPun
left a comment
There was a problem hiding this comment.
this doesn't seem to have fixed the issue. For instance I run
make; ./utility.sh ra --png a a
and after crashing the utility.log is still zero bytes
|
Fair. I've unlinked the utility ticket. This does fix the debugger case for sure, so must be something else going on with that one. |
435c82c to
a6116e4
Compare
|
Applying this same fix across all our |
|
So i was curious why it would not end up logged. The cause is that top level exception are not caught. Looking at the stack trace the program is aborted - on my system even a core is dumped. The final clause is never reached.
The solution likely is to add |
a6116e4 to
97c7e15
Compare
|
That is indeed the solution this PR applies. |
When the process is running, we use a finally block to call Log.Dispose and flush any outstanding logs to disk before the process exits. This works when we handle any exception in a matching catch block. When the exception is unhandled, then the finally block will not run and instead the process will just exit. To fix this, flush the logs inside a catch block instead before rethrowing the error. This ensures we get logs even when crashing.
97c7e15 to
544794d
Compare
When the process is running, we use a finally block to call Log.Dispose and flush any outstanding logs to disk before the process exits. This works when we handle any exception in a matching catch block.
When the exception is unhandled, then the finally block will not run and instead the process will just exit. To fix this, flush the logs inside a catch block instead before rethrowing the error. This ensures we get logs even when crashing.
Fixes #20733