quill icon indicating copy to clipboard operation
quill copied to clipboard

Call LOG_BACKTRACE in signal handler

Open BenjaminBeichler opened this issue 2 years ago • 1 comments

Is it safe (i.e. defined behavior) to use LOG_BACKTRACE in a signal handler? It would even make sense to have a flag to log a backtrace, when receiving a SIGSEV. With c++17 the restrictions for signal handlers are a bit more relaxed, but I'm unsure, whether it is safe. Nonetheless, a statement about this in the documentation would be helpful.

BenjaminBeichler avatar Aug 17 '21 16:08 BenjaminBeichler

Sorry for the late response.

I am not sure to answer 100% but I am quite confident that it will be fine.

LOG_INFO macros are called inside the signal handler without any issues. LOG_BACKTRACE doesn't do many more things, when the log message is received by the backend thread it will be stored in a buffer and will be latter on logged only if certain criteria are met.

However, I don't know how useful it would be to use LOG_BACKTRACE when you receive a SIGSEV. In that care most programs will probably want to LOG something immediately and then terminate.

odygrd avatar May 18 '22 21:05 odygrd